|
| 1 | +import pytest |
| 2 | +from rec_to_binaries.binary_utils import ( |
| 3 | + TrodesBinaryFormatError, |
| 4 | + TrodesBinaryReader, |
| 5 | + TrodesLFPBinaryLoader, |
| 6 | + TrodesTimestampBinaryLoader, |
| 7 | + TrodesSpikeBinaryLoader, |
| 8 | + TrodesPosBinaryLoader, |
| 9 | + TrodesDIOBinaryLoader, |
| 10 | +) |
| 11 | + |
| 12 | +def test_TrodesBinaryReader_first_line_not_Start_settings_error(e2etests_directory_path): |
| 13 | + file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_test_first_line_exception.txt' |
| 14 | + |
| 15 | + with pytest.raises(TrodesBinaryFormatError) as ex: |
| 16 | + trodes_binary_reader = TrodesBinaryReader(file_path) |
| 17 | + |
| 18 | + |
| 19 | +def test_TrodesBinaryReader_more_than_1000_length_error(e2etests_directory_path): |
| 20 | + file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_test_more_than_1000_line_exception.txt' |
| 21 | + |
| 22 | + with pytest.raises(TrodesBinaryFormatError): |
| 23 | + trodes_binary_reader = TrodesBinaryReader(file_path) |
| 24 | + |
| 25 | +def test_TrodesBinaryReader_check_if_valid_file_is_read(e2etests_directory_path): |
| 26 | + file_path = f'{e2etests_directory_path}/test_data/TrodesBinaryReader_check_if_valid_file_is_read.txt' |
| 27 | + trodes_binary_reader = TrodesBinaryReader(file_path) |
| 28 | + |
| 29 | + assert trodes_binary_reader.data_start_byte == 43 |
| 30 | + assert trodes_binary_reader.header_params == {'a': '1', 'data': '2'} |
| 31 | + |
| 32 | +def test_TrodesLFPBinaryLoader_check_if_file_can_be_read(e2etests_directory_path): |
| 33 | + file_path = f'{e2etests_directory_path}/test_data/TrodesLFPBinaryLoader_test_file_read.txt' |
| 34 | + trodes_LFP_binary_loader = TrodesLFPBinaryLoader(file_path) |
| 35 | + |
| 36 | + assert trodes_LFP_binary_loader.header_params['Original_file'] == 'test_Original_file' |
| 37 | + assert trodes_LFP_binary_loader.header_params['Trode_ID'] == 'test_Trode_ID' |
| 38 | + assert trodes_LFP_binary_loader.header_params['Trode_channel'] == 'test_Trode_channel' |
| 39 | + assert trodes_LFP_binary_loader.header_params['Clock rate'] == 'test_Clock rate' |
| 40 | + assert trodes_LFP_binary_loader.header_params['Voltage_scaling'] == 'test_Voltage_scaling' |
| 41 | + assert trodes_LFP_binary_loader.header_params['Decimation'] == 'test_Decimation' |
| 42 | + assert trodes_LFP_binary_loader.header_params['First_timestamp'] == 'test_First_timestamp' |
| 43 | + assert trodes_LFP_binary_loader.header_params['Reference'] == 'test_Reference' |
| 44 | + assert trodes_LFP_binary_loader.header_params['Low_pass_filter'] == 'test_Low_pass_filter' |
| 45 | + assert trodes_LFP_binary_loader.header_params['Fields'] == 'test_Fields' |
| 46 | + |
| 47 | +def test_TrodesTimestampBinaryLoader_check_if_file_can_be_read(e2etests_directory_path): |
| 48 | + file_path = f'{e2etests_directory_path}/test_data/TrodesTimestampBinaryLoader_test_file_read.txt' |
| 49 | + trodes_timestamp_binary_loader = TrodesTimestampBinaryLoader(file_path) |
| 50 | + |
| 51 | + assert trodes_timestamp_binary_loader.header_params['Byte_order'] == 'test_Byte_order' |
| 52 | + assert trodes_timestamp_binary_loader.header_params['Original_file'] == 'test_Original_file' |
| 53 | + assert trodes_timestamp_binary_loader.header_params['Clock rate'] == 'test_Clock rate' |
| 54 | + assert trodes_timestamp_binary_loader.header_params['Decimation'] == 'test_Decimation' |
| 55 | + assert trodes_timestamp_binary_loader.header_params['Time_offset'] == 'test_Time_offset' |
| 56 | + assert trodes_timestamp_binary_loader.header_params['Fields'] == 'test_Fields' |
| 57 | + |
| 58 | +def test_TrodesSpikeBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): |
| 59 | + file_path = f'{e2etests_directory_path}/test_data/TrodesSpikeBinaryLoader_test_file_read.txt' |
| 60 | + trodes_spike_binary_loader = TrodesSpikeBinaryLoader(file_path) |
| 61 | + |
| 62 | + |
| 63 | + assert trodes_spike_binary_loader.header_params['Original_file'] == 'test_Original_file' |
| 64 | + assert trodes_spike_binary_loader.header_params['nTrode_ID'] == '1' |
| 65 | + assert trodes_spike_binary_loader.num_channels == 10 |
| 66 | + assert trodes_spike_binary_loader.header_params['Clock rate'] == '3' |
| 67 | + assert trodes_spike_binary_loader.header_params['Voltage_scaling'] == 'v' |
| 68 | + assert trodes_spike_binary_loader.header_params['Time_offset'] == '4' |
| 69 | + assert trodes_spike_binary_loader.header_params['Threshold'] == '5' |
| 70 | + assert trodes_spike_binary_loader.header_params['Spike_invert'] == 't' |
| 71 | + assert trodes_spike_binary_loader.header_params['Reference'] == '6' |
| 72 | + assert trodes_spike_binary_loader.header_params['ReferenceNTrode'] == '7' |
| 73 | + assert trodes_spike_binary_loader.header_params['ReferenceChannel'] == '8' |
| 74 | + assert trodes_spike_binary_loader.header_params['Filter'] == 't' |
| 75 | + assert trodes_spike_binary_loader.header_params['lowPassFilter'] == 'y' |
| 76 | + assert trodes_spike_binary_loader.header_params['highPassFilter'] == 'n' |
| 77 | + assert trodes_spike_binary_loader.header_params['Fields'] == 'test_field' |
| 78 | + assert trodes_spike_binary_loader.spike_rec_size == 804 |
| 79 | + |
| 80 | +@pytest.mark.skip(reason="I have to figure out why pos_list stays empty") |
| 81 | +def test_TrodesPosBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): |
| 82 | + file_path = f'{e2etests_directory_path}/test_data/TrodesPosBinaryLoader_check_if_data_file_is_read.txt' |
| 83 | + trodes_pos_binary_loader = TrodesPosBinaryLoader(file_path) |
| 84 | + |
| 85 | + breakpoint() |
| 86 | + |
| 87 | + assert trodes_pos_binary_loader.header_params['threshold'] == 'test_threshold' |
| 88 | + assert trodes_pos_binary_loader.header_params['dark'] == 'test_dark' |
| 89 | + assert trodes_pos_binary_loader.header_params['clockrate'] == 'test_clockrate' |
| 90 | + assert trodes_pos_binary_loader.header_params['field_str'] == 'test_Fields' |
| 91 | + assert trodes_pos_binary_loader.rec_size == 12 |
| 92 | + assert trodes_pos_binary_loader.unpack_format == 'IHHHH' |
| 93 | + |
| 94 | +@pytest.mark.skip(reason="I have to figure out why pos_list stays empty") |
| 95 | +def test_TrodesDIOBinaryLoader_check_if_data_file_is_read(e2etests_directory_path): |
| 96 | + file_path = f'{e2etests_directory_path}/test_data/TrodesPosBinaryLoader_check_if_data_file_is_read.txt' |
| 97 | + trodes_pos_binary_loader = TrodesDIOBinaryLoader(file_path) |
| 98 | + |
| 99 | + assert True |
0 commit comments