def test_Object(eflr_data: DataForEFLR): eflr_data.rewind() template = EFLR.Template() template.read(eflr_data.template) obj = EFLR.Object(eflr_data.object, template) assert obj.name == RepCode.ObjectName(O=0, C=0, I=b'TIME') assert eflr_data.object.remain == 1 # Object byte terminates template
def _create_log_pass(): ld = File.LogicalData(BYTES_CHANNEL) channels = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) ld = File.LogicalData(BYTES_FRAME) frame = EFLR.ExplicitlyFormattedLogicalRecord(4, ld) log_pass = LogPass.log_pass_from_RP66V1(frame, channels) return log_pass
def test_ExplicitlyFormattedLogicalRecord_eq(): ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD) eflr_a = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) ld.rewind() eflr_b = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert eflr_a == eflr_b assert eflr_a != 1
def test_Object_attr_label_map(): OBJECT_DATA_FROM_STANDARD[0].rewind() template = EFLR.Template() template.read(OBJECT_DATA_FROM_STANDARD[0].template) obj = EFLR.Object(OBJECT_DATA_FROM_STANDARD[0].object, template) assert obj.attr_label_map == { b'LONG-NAME': 0, b'ELEMENT-LIMIT': 1, b'REPRESENTATION-CODE': 2, b'UNITS': 3, b'DIMENSION': 4, }
def test_ExplicitlyFormattedLogicalRecord_dupe_later_copy(ld): """Hmm actually this should fail and only have one object there ???""" ld.rewind() with duplicate_object_strategy( TotalDepth.RP66V1.core.LogicalRecord.Duplicates. DuplicateObjectStrategy.REPLACE_LATER_COPY): eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) result = eflr.str_long() # print(result) expected = """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'> Template [5]: CD: 001 10100 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: None CD: 001 10101 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1] CD: 001 10101 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2] CD: 001 10000 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: None CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1] Objects [2]: OBNAME: O: 0 C: 0 I: b'TIME' CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')] CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1] CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2] CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'S'] CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1] OBNAME: O: 0 C: 1 I: b'TIME' CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')] CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1] CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2] CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'S'] CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]""" for a, b in zip(result.split('\n'), expected.split('\n')): assert a == b assert result == expected
def __enter__(self): """Context manager support.""" self._logical_record_index._enter() self.logical_files = [] for lr_index in range(len(self._logical_record_index)): # TODO: This is greedy and for IFLRs we could only read a partial amount for performance. # See FrameArray.x_axis_len_input_bytes file_logical_data = self._logical_record_index.get_file_logical_data(lr_index, 0, -1) assert file_logical_data.is_sealed() if not file_logical_data.lr_is_encrypted: if file_logical_data.lr_is_eflr: # EFLRs eflr = EFLR.ExplicitlyFormattedLogicalRecord(file_logical_data.lr_type, file_logical_data.logical_data) if len(self.logical_files) == 0 or self.logical_files[-1].is_next(eflr): self.logical_files.append(LogicalFile(self._logical_record_index, file_logical_data, eflr)) else: self.logical_files[-1].add_eflr(file_logical_data, eflr) else: # IFLRs if len(self.logical_files) == 0: raise ExceptionLogicalIndexCtor('IFLR when there are no Logical Files.') iflr = IFLR.IndirectlyFormattedLogicalRecord(file_logical_data.lr_type, file_logical_data.logical_data) if iflr.remain > 0: self.logical_files[-1].add_iflr(file_logical_data, iflr) # else: # logger.warning(f'Ignoring empty IFLR at {file_logical_data.position}') return self
def test_ExplicitlyFormattedLogicalRecord_key_values(sort_order, expected): ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD_SINGLE_OBJECT) eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) result = eflr.key_values( stringify_function=stringify.stringify_object_by_type, sort=sort_order) # print(result) assert result == expected
def test_ExplicitlyFormattedLogicalRecord_key_value_raises(): ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD) eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert not eflr.is_key_value() with pytest.raises(EFLR.ExceptionEFLR) as err: eflr.key_values(stringify_function=stringify.stringify_object_by_type, sort=True) assert err.value.args[0] == 'Can not represent EFLR as key->value table.'
def test_AttributeBase(cd, expected_label, expected_count, expected_rep_code, expected_units, expected_value): result = EFLR.AttributeBase(cd) assert result.label == expected_label assert result.count == expected_count assert result.rep_code == expected_rep_code assert result.units == expected_units assert result.value == expected_value
def test_ExplicitlyFormattedLogicalRecord_table_as_string( sort_order, expected): ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD) eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) result = eflr.table_as_strings( stringify_function=stringify.stringify_object_by_type, sort=sort_order) # print(result) assert result == expected
def test_ExplicitlyFormattedLogicalRecord_dupe_exact_raise(ld): ld.rewind() with duplicate_object_strategy(TotalDepth.RP66V1.core.LogicalRecord. Duplicates.DuplicateObjectStrategy.RAISE): with pytest.raises(EFLR.ExceptionEFLRSetDuplicateObjectNames) as err: EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert err.value.args == ( "Duplicate Object OBNAME: O: 0 C: 0 I: b'TIME' already seen in the EFLR Set type: b'CHANNEL' name: b'0'.", )
def test_TemplateAttribute(cd, ld, expected_label, expected_count, expected_rep_code, expected_units, expected_value): result = EFLR.TemplateAttribute(cd, ld) assert result.label == expected_label assert result.count == expected_count assert result.rep_code == expected_rep_code assert result.units == expected_units assert result.value == expected_value assert ld.remain == 0
def test_Template_header_as_strings(ld): template = EFLR.Template() template.read(ld) expected = [ 'LONG-NAME', 'ELEMENT-LIMIT', 'REPRESENTATION-CODE', 'UNITS', 'DIMENSION' ] assert template.header_as_strings( stringify.stringify_object_by_type) == expected
def test_eflr_channel_attributes(): ld = File.LogicalData(BYTES_CHANNEL) eflr = EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld) print(eflr) print(eflr.str_long()) assert str( eflr ) == "<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'59'>" assert eflr.str_long( ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'59'>
def test_Template(ld): template = EFLR.Template() template.read(ld) assert ld.remain == 1 # Object byte terminates template assert len(template.attrs) == 5 expected = { b'LONG-NAME': 0, b'ELEMENT-LIMIT': 1, b'REPRESENTATION-CODE': 2, b'UNITS': 3, b'DIMENSION': 4, } assert template.attr_label_map == expected
def test_eflr_frame_attributes(): ld = File.LogicalData(BYTES_FRAME) frame = EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld) assert len(frame.objects) == 1 # print() # print(frame) assert str( frame ) == "<ExplicitlyFormattedLogicalRecord EFLR Set type: b'FRAME' name: b'60'>" # print(frame.str_long()) assert frame.str_long( ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'FRAME' name: b'60'>
def test_eflr_channel_obnames(): ld = File.LogicalData(BYTES_CHANNEL) channels = EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld) channel_obnames = [obj.name for obj in channels.objects] # print(channel_obnames) assert channel_obnames == [ RepCode.ObjectName(O=11, C=0, I=b'DEPT'), RepCode.ObjectName(O=11, C=0, I=b'INC'), RepCode.ObjectName(O=11, C=0, I=b'AZI'), RepCode.ObjectName(O=11, C=0, I=b'MTTVD'), RepCode.ObjectName(O=11, C=0, I=b'SECT'), RepCode.ObjectName(O=11, C=0, I=b'RCN'), RepCode.ObjectName(O=11, C=0, I=b'RCE'), RepCode.ObjectName(O=11, C=0, I=b'DLSEV'), RepCode.ObjectName(O=11, C=0, I=b'TLTS'), ]
def test_eflr_frame_channels(): ld = File.LogicalData(BYTES_FRAME) frame = EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld) obj = frame[0] channels = obj[b'CHANNELS'].value assert len(channels) == 9 assert channels == [ RepCode.ObjectName(O=11, C=0, I=b'DEPT'), RepCode.ObjectName(O=11, C=0, I=b'INC'), RepCode.ObjectName(O=11, C=0, I=b'AZI'), RepCode.ObjectName(O=11, C=0, I=b'MTTVD'), RepCode.ObjectName(O=11, C=0, I=b'SECT'), RepCode.ObjectName(O=11, C=0, I=b'RCN'), RepCode.ObjectName(O=11, C=0, I=b'RCE'), RepCode.ObjectName(O=11, C=0, I=b'DLSEV'), RepCode.ObjectName(O=11, C=0, I=b'TLTS') ]
def write_well_information_to_las( logical_file: LogicalFile.LogicalFile, frame_array: typing.Union[LogPass.FrameArray, None], frame_slice: typing.Union[Slice.Slice, Slice.Sample], ostream: typing.TextIO, ) -> None: """Writes the well information section. Reference: ``[LAS2.0 Las2_Update_Feb2017.pdf Section 5.4 ~W (Well Information)]`` """ # Tuple of (units, value, description) las_map: typing.Dict[str, UnitValueDescription] = extract_well_information_from_origin(logical_file) _add_start_stop_step_to_dictionary(logical_file, frame_array, frame_slice, las_map) eflr: EFLR.ExplicitlyFormattedLogicalRecord for _lrsh_position, eflr in logical_file.eflrs: if eflr.set.type in DLIS_TO_WELL_INFORMATION_LAS_EFLR_MAPPING: bytes_index_map: typing.Dict[bytes, int] = EFLR.reduced_object_map(eflr) for row_key in DLIS_TO_WELL_INFORMATION_LAS_EFLR_MAPPING[eflr.set.type]: if row_key in bytes_index_map: obj = eflr[bytes_index_map[row_key]] # ORIGIN is only key/value so does not have LONG-NAME # PARAMETER does have LONG-NAME units = obj[b'VALUES'].units.decode('ascii') value = stringify.stringify_object_by_type(obj[b'VALUES'].value).strip() descr = stringify.stringify_object_by_type(obj[b'LONG-NAME'].value).strip() # NOTE: Overwriting is possible here. las_map[row_key.decode('ascii')] = UnitValueDescription(units, value, descr) table = [ ['#MNEM.UNIT', 'DATA', 'DESCRIPTION',], ['#----.----', '----', '-----------',], ] for k in WELL_INFORMATION_KEYS: if k in las_map: row = [f'{k:4}.{las_map[k].unit:4}', f'{las_map[k].value}', f': {las_map[k].description}',] else: row = [f'{k:4}.{"":4}', '', ':'] table.append(row) rows = data_table.format_table(table, pad=' ', left_flush=True) ostream.write('~Well Information Section\n') for row in rows: ostream.write(row) ostream.write('\n')
def test_ExplicitlyFormattedLogicalRecord_template(ld): ld.rewind() eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert len(eflr.template) == 5 # ATTRIB[0]: LR assert eflr.template.attrs[0].label == b'LONG-NAME' assert eflr.template.attrs[0].rep_code == 0x17 # ATTRIB[1]: LRV assert eflr.template.attrs[1].label == b'ELEMENT-LIMIT' assert eflr.template.attrs[1].rep_code == 0x12 assert eflr.template.attrs[1].value == [1] # ATTRIB[2]: LRV assert eflr.template.attrs[2].label == b'REPRESENTATION-CODE' assert eflr.template.attrs[2].rep_code == 0x0f assert eflr.template.attrs[2].value[0] == 0x02 # ATTRIB[3]: L assert eflr.template.attrs[3].label == b'UNITS' # ATTRIB[4]: LRV assert eflr.template.attrs[4].label == b'DIMENSION' assert eflr.template.attrs[4].rep_code == 0x12 assert eflr.template.attrs[4].value[0] == 0x01
def test_ExplicitlyFormattedLogicalRecord_dupe_diff_replace(ld, strategy): ld.rewind() with duplicate_object_strategy(strategy): eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) result = eflr.str_long() # print(result) expected = """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'> Template [5]: CD: 001 10100 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: None CD: 001 10101 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1] CD: 001 10101 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2] CD: 001 10000 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: None CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1] Objects [1]: OBNAME: O: 0 C: 0 I: b'TIME' CD: 001 00001 L: b'LONG-NAME' C: 1 R: 23 (OBNAME) U: b'' V: [ObjectName(O=0, C=0, I=b'1')] CD: 001 00000 L: b'ELEMENT-LIMIT' C: 1 R: 18 (UVARI) U: b'' V: [1] CD: 001 00000 L: b'REPRESENTATION-CODE' C: 1 R: 15 (USHORT) U: b'' V: [2] CD: 001 00001 L: b'UNITS' C: 1 R: 19 (IDENT) U: b'' V: [b'SECONDS'] CD: 001 10101 L: b'DIMENSION' C: 1 R: 18 (UVARI) U: b'' V: [1]""" for a, b in zip(result.split('\n'), expected.split('\n')): assert a == b assert result == expected
def test_ExplicitlyFormattedLogicalRecord_objects(ld): ld.rewind() eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert len(eflr.template) == 5 assert len(eflr.objects) == 3 ## Object #1 obj_index: int = 0 assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME') assert len(eflr.objects[0].attrs) == len(eflr.template) # Attribute 0 attr_index = 0 assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.ObjectName(0, 0, b'1') ] # Attribute 1 attr_index = 1 assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [1] # Attribute 2 attr_index = 2 assert eflr.objects[obj_index].attrs[ attr_index].label == b'REPRESENTATION-CODE' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.REP_CODE_STR_TO_INT['FSINGL'] ] # Attribute 3 attr_index = 3 assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [b'S'] # Attribute 4 attr_index = 4 assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [1] ## Object #2 obj_index: int = 1 assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME') assert len(eflr.objects[0].attrs) == len(eflr.template) # Attribute 0 attr_index = 0 assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.ObjectName(0, 0, b'2') ] # Attribute 1 attr_index = 1 assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [1] # Attribute 2 attr_index = 2 assert eflr.objects[obj_index].attrs[ attr_index].label == b'REPRESENTATION-CODE' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.REP_CODE_STR_TO_INT['FDOUBL'] ] # Attribute 3 attr_index = 3 assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [b'PSI'] # Attribute 4 attr_index = 4 assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [1] ## Object #3 obj_index: int = 2 assert eflr.objects[0].name == RepCode.ObjectName(0, 0, b'TIME') assert len(eflr.objects[0].attrs) == len(eflr.template) # Attribute 0 attr_index = 0 assert eflr.objects[obj_index].attrs[attr_index].label == b'LONG-NAME' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['OBNAME'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.ObjectName(0, 0, b'3') ] # Attribute 1 attr_index = 1 assert eflr.objects[obj_index].attrs[attr_index].label == b'ELEMENT-LIMIT' assert eflr.objects[obj_index].attrs[attr_index].count == 2 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [8, 20] # Attribute 2 attr_index = 2 assert eflr.objects[obj_index].attrs[ attr_index].label == b'REPRESENTATION-CODE' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['USHORT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' # See above for: NOTE: [RP66V1 Error] assert eflr.objects[obj_index].attrs[attr_index].value == [ RepCode.REP_CODE_STR_TO_INT['SNORM'] ] # Attribute 3 attr_index = 3 assert eflr.objects[obj_index].attrs[attr_index].label == b'UNITS' assert eflr.objects[obj_index].attrs[attr_index].count == 1 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['IDENT'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value is None # Attribute 4 attr_index = 4 assert eflr.objects[obj_index].attrs[attr_index].label == b'DIMENSION' assert eflr.objects[obj_index].attrs[attr_index].count == 2 assert eflr.objects[obj_index].attrs[ attr_index].rep_code == RepCode.REP_CODE_STR_TO_INT['UVARI'] assert eflr.objects[obj_index].attrs[attr_index].units == b'' assert eflr.objects[obj_index].attrs[attr_index].value == [8, 10]
def test_eflr_channel_ctor(): ld = File.LogicalData(BYTES_CHANNEL) EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'CHANNEL'], ld)
def test_Set_raises_logical_data(ld, expected): ld.seek(1) with pytest.raises(EFLR.ExceptionEFLRSet) as err: EFLR.Set(ld) assert err.value.args[0] == expected
def test_ExplicitlyFormattedLogicalRecord_logical_data_consumed(ld): eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert eflr.logical_data_consumed == 155
def test_eflr_frame_ctor(): ld = File.LogicalData(BYTES_FRAME) EFLR.ExplicitlyFormattedLogicalRecord( Types.EFLR_PUBLIC_SET_TYPE_TO_CODE_MAP[b'FRAME'], ld)
def test_ExplicitlyFormattedLogicalRecord_dupe_exact_default(ld): ld.rewind() eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) # print(eflr.str_long()) assert eflr.str_long( ) == """<ExplicitlyFormattedLogicalRecord EFLR Set type: b'CHANNEL' name: b'0'>
def test_ExplicitlyFormattedLogicalRecord_set(ld): eflr = EFLR.ExplicitlyFormattedLogicalRecord(3, ld) assert eflr.set.type == b'CHANNEL' assert eflr.set.name == b'0'
def test_AttributeBase_raises(cd, expected): with pytest.raises(EFLR.ExceptionEFLRAttribute) as err: EFLR.AttributeBase(cd) assert err.value.args[0] == expected
def test_Set_raises(ld, expected): with pytest.raises(EFLR.ExceptionEFLRSet) as err: EFLR.Set(ld) assert err.value.args[0] == expected