def test_iodi_get_qualifier_tree_number(self): """ Tests the IODI insertion of a `QualifierTreeNumber` record via the `iodi_qualifier_tree_number` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create fixture records. qualifier_id, qualifier_refr = create_qualifier(dal=self.dal) tree_number_id, tree_number_id_refr = create_tree_number(dal=self.dal) # IODI a new `QualifierTreeNumber` record. obj_id = self.dal.iodi_qualifier_tree_number( qualifier_id=qualifier_id, tree_number_id=tree_number_id, ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get( QualifierTreeNumber, obj_id, ) # type: QualifierTreeNumber # Assert that the different fields of the record match. self.assertEqual(obj.qualifier_tree_number_id, 1) self.assertEqual(obj.qualifier_id, qualifier_id) self.assertEqual(obj.tree_number_id, tree_number_id)
def test_iodu_get_entry_combination(self): """ Tests the IODU insertion of a `EntryCombination` record via the `iodu_entry_combination` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # IODU a new `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get(EntryCombination, obj_id) # type: EntryCombination # Assert that the different fields of the record match. self.assertEqual(obj.entry_combination_id, obj_id) self.assertEqual(obj.descriptor_id, descriptor_id) self.assertEqual(obj.qualifier_id, qualifier_id) self.assertEqual(obj.combination_type, EntryCombinationType.ECIN)
def test_delete_descriptor_allowable_qualifier(self): """ Tests the deletion of a `DescriptorAllowableQualifier` record via the `delete` method of the `DalMesh` class. """ # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # IODU a new `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="abbreviation", ) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(DescriptorAllowableQualifier, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get( DescriptorAllowableQualifier, obj_id, ) # type: DescriptorAllowableQualifier self.assertIsNone(obj)
def test_iodu_get_descriptor_allowable_qualifier(self): """ Tests the IODU insertion of a `DescriptorAllowableQualifier` record via the `iodu_descriptor_allowable_qualifier` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # IODU a new `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="abbreviation", ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get( DescriptorAllowableQualifier, obj_id, ) # type: DescriptorAllowableQualifier # Assert that the different fields of the record match. self.assertEqual(obj.descriptor_allowable_qualifier_id, obj_id) self.assertEqual(obj.descriptor_id, descriptor_id) self.assertEqual(obj.qualifier_id, qualifier_id) self.assertEqual(obj.abbreviation, "abbreviation")
def test_iodi_get_supplemental_heading_mapped_to(self): """ Tests the IODI insertion of a `SupplementalHeadingMappedTo` record via the `iodi_supplemental_heading_mapped_to` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create fixture records. descriptor_id, _ = create_descriptor(dal=self.dal) qualifier_id, _ = create_qualifier(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) supplemental_id, _ = create_supplemental(dal=self.dal) # IODI a new `SupplementalHeadingMappedTo` record. obj_id = self.dal.iodi_supplemental_heading_mapped_to( supplemental_id=supplemental_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get( SupplementalHeadingMappedTo, obj_id, ) # type: SupplementalHeadingMappedTo # Assert that the different fields of the record match. self.assertEqual(obj.supplemental_heading_mapped_to_id, 1) self.assertEqual(obj.supplemental_id, supplemental_id) self.assertEqual(obj.entry_combination_id, entry_combination_id)
def test_iodi_get_descriptor_entry_combination(self): """ Tests the IODI insertion of a `DescriptorEntryCombination` record via the `iodi_descriptor_entry_combination` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create fixture records. qualifier_id, _ = create_qualifier(dal=self.dal) descriptor_id, _ = create_descriptor(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) # IODI a new `DescriptorEntryCombination` record. obj_id = self.dal.iodi_descriptor_entry_combination( descriptor_id=descriptor_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get( DescriptorEntryCombination, obj_id, ) # type: DescriptorEntryCombination # Assert that the different fields of the record match. self.assertEqual(obj.descriptor_entry_combination_id, 1) self.assertEqual(obj.descriptor_id, descriptor_id) self.assertEqual(obj.entry_combination_id, entry_combination_id)
def test_delete_supplemental_heading_mapped_to(self): """ Tests the deletion of a `SupplementalHeadingMappedTo` record via the `delete` method of the `DalMesh` class. """ # Create fixture records. descriptor_id, _ = create_descriptor(dal=self.dal) qualifier_id, _ = create_qualifier(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) supplemental_id, _ = create_supplemental(dal=self.dal) # IODI a new `SupplementalHeadingMappedTo` record. obj_id = self.dal.iodi_supplemental_heading_mapped_to( supplemental_id=supplemental_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(SupplementalHeadingMappedTo, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get( SupplementalHeadingMappedTo, obj_id, ) # type: SupplementalHeadingMappedTo self.assertIsNone(obj)
def test_delete_descriptor_entry_combination(self): """ Tests the deletion of a `DescriptorEntryCombination` record via the `delete` method of the `DalMesh` class. """ # Create fixture records. qualifier_id, _ = create_qualifier(dal=self.dal) descriptor_id, _ = create_descriptor(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) # IODI a new `DescriptorEntryCombination` record. obj_id = self.dal.iodi_descriptor_entry_combination( descriptor_id=descriptor_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(DescriptorEntryCombination, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get( DescriptorEntryCombination, obj_id, ) # type: DescriptorEntryCombination self.assertIsNone(obj)
def test_delete_entry_combination(self): """ Tests the deletion of a `EntryCombination` record via the `delete` method of the `DalMesh` class. """ # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # IODU a new `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(EntryCombination, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get(EntryCombination, obj_id) # type: EntryCombination self.assertIsNone(obj)
def test_delete_qualifier_tree_number(self): """ Tests the deletion of a `QualifierTreeNumber` record via the `delete` method of the `DalMesh` class. """ # Create fixture records. qualifier_id, qualifier_refr = create_qualifier(dal=self.dal) tree_number_id, tree_number_id_refr = create_tree_number(dal=self.dal) # IODI a new `QualifierTreeNumber` record. obj_id = self.dal.iodi_qualifier_tree_number( qualifier_id=qualifier_id, tree_number_id=tree_number_id, ) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(QualifierTreeNumber, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get( QualifierTreeNumber, obj_id, ) # type: QualifierTreeNumber self.assertIsNone(obj)
def test_update_entry_combination(self): """ Tests the update of a `EntryCombination` record via the `update` method of the `DalMesh` class. """ # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # IODU a new `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) # Retrieve the new record. obj_original = self.dal.get( EntryCombination, obj_id, ) # type: EntryCombination # Assert that the different fields of the record match. self.assertEqual(obj_original.entry_combination_id, obj_id) self.assertEqual(obj_original.descriptor_id, descriptor_id) self.assertEqual(obj_original.qualifier_id, qualifier_id) self.assertEqual( obj_original.combination_type, EntryCombinationType.ECIN, ) # Update the record. self.dal.update_attr_value( EntryCombination, obj_id, "combination_type", EntryCombinationType.ECOUT, ) # Retrieve the updated record. obj_updated = self.dal.get( EntryCombination, obj_id, ) # type: EntryCombination # Assert that the ID remained the same. self.assertEqual(obj_updated.entry_combination_id, 1) # Assert that attribute changed. self.assertEqual( obj_updated.combination_type, EntryCombinationType.ECOUT, )
def test_iodu_qualifier_duplicate(self): """ Tests the IODU insertion of duplicate `Qualifier` records to ensure deduplication functions as intended. """ # Create a new `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal) self.assertEqual(obj_id, 1) # IODU the same `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal) self.assertEqual(obj_id, 1) # IODU the same `Qualifier` record with a changed `history_note` field # which should trigger an update on the existing record. obj_id, refr = create_qualifier(dal=self.dal, history_note="different history note") self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get(Qualifier, obj_id) # type: Qualifier self.assertEqual(obj.history_note, "different history note") # IODU a new `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal, ui="Q000000982", name="NewQualifier") self.assertEqual(obj_id, 4) # IODU the same `Qualifier` record as before. obj_id, refr = create_qualifier(dal=self.dal, ui="Q000000982", name="NewQualifier") self.assertEqual(obj_id, 4)
def test_update_descriptor_allowable_qualifier(self): """ Tests the update of a `DescriptorAllowableQualifier` record via the `update` method of the `DalMesh` class. """ # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # IODU a new `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="abbreviation", ) # Retrieve the new record. obj_original = self.dal.get( DescriptorAllowableQualifier, obj_id, ) # type: DescriptorAllowableQualifier # Assert that the different fields of the record match. self.assertEqual(obj_original.descriptor_allowable_qualifier_id, obj_id) self.assertEqual(obj_original.descriptor_id, descriptor_id) self.assertEqual(obj_original.qualifier_id, qualifier_id) self.assertEqual(obj_original.abbreviation, "abbreviation") # Update the record. self.dal.update_attr_value( DescriptorAllowableQualifier, obj_id, "abbreviation", "NewAbbreviation", ) # Retrieve the updated record. obj_updated = self.dal.get( DescriptorAllowableQualifier, obj_id, ) # type: DescriptorAllowableQualifier # Assert that the ID remained the same. self.assertEqual(obj_updated.descriptor_allowable_qualifier_id, 1) # Assert that attribute changed. self.assertEqual(obj_updated.abbreviation, "NewAbbreviation")
def test_delete_qualifier(self): """ Tests the deletion of a `Qualifier` record via the `delete` method of the `DalMesh` class. """ # Create a new `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal) self.assertEqual(obj_id, 1) # Delete the new record. self.dal.delete(Qualifier, obj_id) # (Attempt to) retrieve the deleted record. obj = self.dal.get(Qualifier, obj_id) # type: Qualifier self.assertIsNone(obj)
def test_iodi_supplemental_heading_mapped_to_duplicate(self): """ Tests the IODI insertion of duplicate `SupplementalHeadingMappedTo` records to ensure deduplication functions as intended. """ # Create fixture records. descriptor_id, _ = create_descriptor(dal=self.dal) qualifier_id, _ = create_qualifier(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) supplemental_id, _ = create_supplemental(dal=self.dal) supplemental_02_id, _ = create_supplemental( dal=self.dal, ui="UI2", name="Name2" ) # IODI a new `SupplementalHeadingMappedTo` record. obj_id = self.dal.iodi_supplemental_heading_mapped_to( supplemental_id=supplemental_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # IODI an identical `SupplementalHeadingMappedTo` record. obj_id = self.dal.iodi_supplemental_heading_mapped_to( supplemental_id=supplemental_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # IODI a new `SupplementalHeadingMappedTo` record. obj_id = self.dal.iodi_supplemental_heading_mapped_to( supplemental_id=supplemental_02_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 3)
def test_iodi_descriptor_entry_combination_duplicate(self): """ Tests the IODI insertion of duplicate `DescriptorEntryCombination` records to ensure deduplication functions as intended. """ # Create fixture records. qualifier_id, _ = create_qualifier(dal=self.dal) descriptor_id, _ = create_descriptor(dal=self.dal) entry_combination_id, _ = create_entry_combination( dal=self.dal, descriptor_id=descriptor_id, qualifier_id=qualifier_id, ) descriptor_02_id, _ = create_descriptor( dal=self.dal, ui="UI2", name="Name2", ) # IODI a new `DescriptorEntryCombination` record. obj_id = self.dal.iodi_descriptor_entry_combination( descriptor_id=descriptor_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # IODI an identical `DescriptorEntryCombination` record. obj_id = self.dal.iodi_descriptor_entry_combination( descriptor_id=descriptor_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 1) # IODI a new `DescriptorEntryCombination` record. obj_id = self.dal.iodi_descriptor_entry_combination( descriptor_id=descriptor_02_id, entry_combination_id=entry_combination_id, ) self.assertEqual(obj_id, 3)
def test_update_qualifier(self): """ Tests the update of a `Qualifier` record via the `update` method of the `DalMesh` class. """ # Create a new `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal) # Retrieve the new record. obj_original = self.dal.get(Qualifier, obj_id) # type: Qualifier # Assert that the different fields of the record match. self.assertEqual(obj_original.qualifier_id, obj_id) self.assertEqual(obj_original.ui, refr["ui"]) self.assertEqual(obj_original.name, refr["name"]) self.assertEqual(obj_original.created, refr["created"]) self.assertEqual(obj_original.revised, refr["revised"]) self.assertEqual(obj_original.established, refr["established"]) self.assertEqual(obj_original.annotation, refr["annotation"]) self.assertEqual(obj_original.history_note, refr["history_note"]) self.assertEqual(obj_original.online_note, refr["online_note"]) # Update the record. self.dal.update_attr_value( Qualifier, obj_id, "history_note", "different history note", ) # Retrieve the updated record. obj_updated = self.dal.get(Qualifier, obj_id) # type: Qualifier # Assert that the ID remained the same. self.assertEqual(obj_updated.qualifier_id, 1) # Assert that attribute changed. self.assertEqual(obj_updated.history_note, "different history note")
def test_iodu_get_qualifier(self): """ Tests the IODU insertion of a `Qualifier` record via the `iodu_qualifier` method of the `DalMesh` class and its retrieval via the `get` method. """ # Create a new `Qualifier` record. obj_id, refr = create_qualifier(dal=self.dal) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get(Qualifier, obj_id) # type: Qualifier # Assert that the different fields of the record match. self.assertEqual(obj.qualifier_id, obj_id) self.assertEqual(obj.ui, refr["ui"]) self.assertEqual(obj.name, refr["name"]) self.assertEqual(obj.created, refr["created"]) self.assertEqual(obj.revised, refr["revised"]) self.assertEqual(obj.established, refr["established"]) self.assertEqual(obj.annotation, refr["annotation"]) self.assertEqual(obj.history_note, refr["history_note"]) self.assertEqual(obj.online_note, refr["online_note"])
def test_iodi_qualifier_tree_number_duplicate(self): """ Tests the IODI insertion of duplicate `QualifierTreeNumber` records to ensure deduplication functions as intended. """ # Create fixture records. qualifier_id, _ = create_qualifier(dal=self.dal) tree_number_id, _ = create_tree_number(dal=self.dal) tree_number_02_id, _ = create_tree_number( dal=self.dal, tree_number="B13.869.106", ) # IODI a new `QualifierTreeNumber` record. obj_id = self.dal.iodi_qualifier_tree_number( qualifier_id=qualifier_id, tree_number_id=tree_number_id, ) self.assertEqual(obj_id, 1) # IODI an identical `QualifierTreeNumber` record. obj_id = self.dal.iodi_qualifier_tree_number( qualifier_id=qualifier_id, tree_number_id=tree_number_id, ) self.assertEqual(obj_id, 1) # IODI a new `QualifierTreeNumber` record. obj_id = self.dal.iodi_qualifier_tree_number( qualifier_id=qualifier_id, tree_number_id=tree_number_02_id, ) self.assertEqual(obj_id, 3)
def test_iodu_entry_combination(self): """ Tests the IODU insertion of duplicate `EntryCombination` records to ensure deduplication functions as intended. """ # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # Create a second `Descriptor` record as a fixture. descriptor_02_id, _ = create_descriptor( dal=self.dal, ui="UI2", name="Name2", ) # IODU a new `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 1) # IODU the same `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 1) # IODU the same `EntryCombination` record with a changed # `combination_type` field which should trigger an update on the # existing record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECOUT, ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get(EntryCombination, obj_id) # type: EntryCombination self.assertEqual(obj.combination_type, EntryCombinationType.ECOUT) # IODU a new `EntryCombination` record. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_02_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 4) # IODU the same `EntryCombination` record as before. obj_id = self.dal.iodu_entry_combination( descriptor_id=descriptor_02_id, qualifier_id=qualifier_id, combination_type=EntryCombinationType.ECIN, ) self.assertEqual(obj_id, 4)
def test_iodu_descriptor_allowable_qualifier(self): """ Tests the IODU insertion of duplicate `DescriptorAllowableQualifier` records to ensure deduplication functions as intended. """ # Create a `Descriptor` record as a fixture. descriptor_id, _ = create_descriptor(dal=self.dal) # Create a `Qualifier` record as a fixture. qualifier_id, _ = create_qualifier(dal=self.dal) # Create a second `Qualifier` record as a fixture. qualifier_02_id, _ = create_qualifier( dal=self.dal, ui="UI2", name="Name2", ) # IODU a new `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="abbreviation", ) self.assertEqual(obj_id, 1) # IODU the same `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="abbreviation", ) self.assertEqual(obj_id, 1) # IODU the same `DescriptorAllowableQualifier` record with a changed # `abbreviation` field which should trigger an update on the existing # record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_id, abbreviation="NewAbbreviation", ) self.assertEqual(obj_id, 1) # Retrieve the new record. obj = self.dal.get( DescriptorAllowableQualifier, obj_id, ) # type: DescriptorAllowableQualifier self.assertEqual(obj.abbreviation, "NewAbbreviation") # IODU a new `DescriptorAllowableQualifier` record. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_02_id, abbreviation="NewAbbreviation", ) self.assertEqual(obj_id, 4) # IODU the same `DescriptorAllowableQualifier` record as before. obj_id = self.dal.iodu_descriptor_allowable_qualifier( descriptor_id=descriptor_id, qualifier_id=qualifier_02_id, abbreviation="NewAbbreviation", ) self.assertEqual(obj_id, 4)