Exemple #1
0
    def test_delete_concept_related_concept(self):
        """ Tests the deletion of a `ConceptRelatedConcept` record via the
            `delete` method of the `DalMesh` class.
        """

        # Create two `Concept` records as fixtures.
        concept_01_id, _ = create_concept(dal=self.dal, ui="UI1", name="name1")
        concept_02_id, _ = create_concept(dal=self.dal, ui="UI2", name="name2")

        # IODI a new `ConceptRelatedConcept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.BRD,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(ConceptRelatedConcept, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(
            ConceptRelatedConcept,
            obj_id,
        )  # type: ConceptRelatedConcept

        self.assertIsNone(obj)
Exemple #2
0
    def test_iodu_get_concept_related_concept(self):
        """ Tests the IODU insertion of a `ConceptRelatedConcept` record via the
            `iodu_concept_related_concept` method of the `DalMesh` class and its
            retrieval via the `get` method.
        """

        # Create two `Concept` records as fixtures.
        concept_01_id, _ = create_concept(dal=self.dal, ui="UI1", name="name1")
        concept_02_id, _ = create_concept(dal=self.dal, ui="UI2", name="name2")

        # IODI a new `ConceptRelatedConcept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.BRD,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(
            ConceptRelatedConcept,
            obj_id,
        )  # type: ConceptRelatedConcept

        # Assert that the different fields of the record match.
        self.assertEqual(obj.concept_related_concept_id, obj_id)
        self.assertEqual(obj.concept_id, concept_01_id)
        self.assertEqual(obj.related_concept_id, concept_02_id)
        self.assertEqual(obj.relation_name, RelationNameType.BRD)
Exemple #3
0
    def test_iodu_get_descriptor_concept(self):
        """ Tests the IODU insertion of a `DescriptorConcept` record via the
            `iodu_descriptor_concept` 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 `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)

        # IODU a new `DescriptorConcept` record.
        obj_id = self.dal.iodu_descriptor_concept(
            descriptor_id=descriptor_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(DescriptorConcept,
                           obj_id)  # type: DescriptorConcept

        # Assert that the different fields of the record match.
        self.assertEqual(obj.descriptor_concept_id, obj_id)
        self.assertEqual(obj.descriptor_id, descriptor_id)
        self.assertEqual(obj.concept_id, concept_id)
        self.assertEqual(obj.is_preferred, True)
Exemple #4
0
    def test_delete_descriptor_concept(self):
        """ Tests the deletion of a `DescriptorConcept` 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 `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)

        # IODU a new `DescriptorConcept` record.
        obj_id = self.dal.iodu_descriptor_concept(
            descriptor_id=descriptor_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(DescriptorConcept, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(DescriptorConcept,
                           obj_id)  # type: DescriptorConcept

        self.assertIsNone(obj)
    def test_iodu_get_concept_term(self):
        """ Tests the IODU insertion of a `ConceptTerm` record via the
            `iodu_concept_term` method of the `DalMesh` class and its retrieval
            via the `get` method.
        """

        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)
        # Create a `Term` record as a fixture.
        term_id, _ = create_term(dal=self.dal)

        # IODU a new `ConceptTerm` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABB,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(ConceptTerm, obj_id)  # type: ConceptTerm

        # Assert that the different fields of the record match.
        self.assertEqual(obj.concept_term_id, obj_id)
        self.assertEqual(obj.concept_id, concept_id)
        self.assertEqual(obj.term_id, term_id)
        self.assertEqual(obj.is_concept_preferred_term, True)
        self.assertEqual(obj.is_permuted_term, False)
        self.assertEqual(obj.lexical_tag, LexicalTagType.ABB)
        self.assertEqual(obj.is_record_preferred_term, True)
Exemple #6
0
    def test_delete_supplemental_concept(self):
        """ Tests the deletion of a `SupplementalConcept` record via the
            `delete` method of the `DalMesh` class.
        """

        # Create a `Supplemental` record as a fixture.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)

        # IODU a new `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(SupplementalConcept, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(
            SupplementalConcept,
            obj_id,
        )  # type: SupplementalConcept

        self.assertIsNone(obj)
Exemple #7
0
    def test_iodu_get_supplemental_concept(self):
        """ Tests the IODU insertion of a `SupplementalConcept` record via the
            `iodu_supplemental_concept` method of the `DalMesh` class and its
            retrieval via the `get` method.
        """

        # Create a `Supplemental` record as a fixture.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)

        # IODU a new `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(
            SupplementalConcept,
            obj_id,
        )  # type: SupplementalConcept

        # Assert that the different fields of the record match.
        self.assertEqual(obj.supplemental_concept_id, obj_id)
        self.assertEqual(obj.supplemental_id, supplemental_id)
        self.assertEqual(obj.concept_id, concept_id)
        self.assertEqual(obj.is_preferred, True)
Exemple #8
0
    def test_get_joined_mutliple_relationship(self):
        """ Tests the `get_joined` method with multiple relationships."""

        # Create fixture records.
        descriptor_id, _ = create_descriptor(dal=self.dal)
        tree_number_id, _ = create_tree_number(dal=self.dal)
        concept_id, _ = create_concept(dal=self.dal)

        # IODI a new `DescriptorTreeNumber` record.
        self.dal.iodi_descriptor_tree_number(
            descriptor_id=descriptor_id,
            tree_number_id=tree_number_id,
        )

        # IODU a new `DescriptorConcept` record.
        self.dal.iodu_descriptor_concept(
            descriptor_id=descriptor_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        # Retrieve the `Descriptor` join-loaded with its `TreeNumber` and
        # `Concept` record.
        obj = self.dal.get_joined(
            orm_class=Descriptor,
            pk=descriptor_id,
            joined_relationships=["tree_numbers",
                                  "concepts"])  # type: Descriptor

        self.assertEqual(obj.descriptor_id, descriptor_id)
        self.assertIsNotNone(obj.tree_numbers)
        self.assertIsNotNone(obj.concepts)
Exemple #9
0
    def test_iodu_get_concept(self):
        """ Tests the IODU insertion of a `Concept` record via the
            `iodu_concept` method of the `DalMesh` class and its retrieval via
            the `get` method.
        """

        # Create a new `Concept` record.
        obj_id, refr = create_concept(dal=self.dal)

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(Concept, obj_id)  # type: Concept

        # Assert that the different fields of the record match.
        self.assertEqual(obj.concept_id, obj_id)
        self.assertEqual(obj.ui, refr["ui"])
        self.assertEqual(obj.name, refr["name"])
        self.assertEqual(obj.casn1_name, refr["casn1_name"])
        self.assertEqual(obj.registry_number, refr["registry_number"])
        self.assertEqual(obj.scope_note, refr["scope_note"])
        self.assertEqual(
            obj.translators_english_scope_note,
            refr["translators_english_scope_note"],
        )
        self.assertEqual(
            obj.translators_scope_note,
            refr["translators_scope_note"],
        )
    def test_delete_concept_term(self):
        """ Tests the deletion of a `ConceptTerm` record via the `delete` method
            of the `DalMesh` class.
        """

        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)
        # Create a `Term` record as a fixture.
        term_id, _ = create_term(dal=self.dal)

        # IODU a new `ConceptTerm` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABB,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(ConceptTerm, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(ConceptTerm, obj_id)  # type: ConceptTerm

        self.assertIsNone(obj)
Exemple #11
0
    def test_update_concept_related_concept(self):
        """ Tests the update of a `ConceptRelatedConcept` record via the
            `update` method of the `DalMesh` class.
        """

        # Create two `Concept` records as fixtures.
        concept_01_id, _ = create_concept(dal=self.dal, ui="UI1", name="name1")
        concept_02_id, _ = create_concept(dal=self.dal, ui="UI2", name="name2")

        # IODI a new `ConceptRelatedConcept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.BRD,
        )

        # Retrieve the new record.
        obj_original = self.dal.get(ConceptRelatedConcept,
                                    obj_id)  # type: ConceptRelatedConcept

        # Assert that the different fields of the record match.
        self.assertEqual(obj_original.concept_related_concept_id, obj_id)
        self.assertEqual(obj_original.concept_id, concept_01_id)
        self.assertEqual(obj_original.related_concept_id, concept_02_id)
        self.assertEqual(obj_original.relation_name, RelationNameType.BRD)

        # Update the record.
        self.dal.update_attr_value(
            ConceptRelatedConcept,
            obj_id,
            "relation_name",
            RelationNameType.REL,
        )

        # Retrieve the updated record.
        obj_updated = self.dal.get(ConceptRelatedConcept,
                                   obj_id)  # type: ConceptRelatedConcept

        # Assert that the ID remained the same.
        self.assertEqual(obj_updated.concept_related_concept_id, 1)
        # Assert that attribute changed.
        self.assertEqual(obj_updated.relation_name, RelationNameType.REL)
Exemple #12
0
    def test_iodu_concept_duplicate(self):
        """ Tests the IODU insertion of duplicate `Concept` records to ensure
            deduplication functions as intended.
        """

        # Create a new `Concept` record.
        obj_id, refr = create_concept(dal=self.dal)

        self.assertEqual(obj_id, 1)

        # IODU the same `Term` record.
        obj_id, refr = create_concept(dal=self.dal)

        self.assertEqual(obj_id, 1)

        # IODU the same `Term` record with a changed `scope_note` field which
        # should trigger an update on the existing record.
        obj_id, refr = create_concept(dal=self.dal,
                                      scope_note="different scope note")

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(Concept, obj_id)  # type: Concept

        self.assertEqual(obj.scope_note, "different scope note")

        # IODU a new `Concept` record.
        obj_id, refr = create_concept(dal=self.dal,
                                      ui="M0000034",
                                      name="Different name")

        self.assertEqual(obj_id, 4)

        # IODU the same `Concept` record as before.
        obj_id, refr = create_concept(dal=self.dal,
                                      ui="M0000034",
                                      name="Different name")

        self.assertEqual(obj_id, 4)
    def test_update_concept_term(self):
        """ Tests the update of a `ConceptTerm` record via the `update` method
            of the `DalMesh` class.
        """

        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)
        # Create a `Term` record as a fixture.
        term_id, _ = create_term(dal=self.dal)

        # IODU a new `ConceptTerm` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABB,
            is_record_preferred_term=True,
        )

        # Retrieve the new record.
        obj_original = self.dal.get(ConceptTerm, obj_id)  # type: ConceptTerm

        # Assert that the different fields of the record match.
        self.assertEqual(obj_original.concept_term_id, obj_id)
        self.assertEqual(obj_original.concept_id, concept_id)
        self.assertEqual(obj_original.term_id, term_id)
        self.assertEqual(obj_original.is_concept_preferred_term, True)
        self.assertEqual(obj_original.is_permuted_term, False)
        self.assertEqual(obj_original.lexical_tag, LexicalTagType.ABB)
        self.assertEqual(obj_original.is_record_preferred_term, True)

        # Update the record.
        self.dal.update_attr_value(
            ConceptTerm,
            obj_id,
            "lexical_tag",
            LexicalTagType.ACR,
        )

        # Retrieve the updated record.
        obj_updated = self.dal.get(ConceptTerm, obj_id)  # type: ConceptTerm

        # Assert that the ID remained the same.
        self.assertEqual(obj_updated.concept_term_id, 1)
        # Assert that attribute changed.
        self.assertEqual(obj_updated.lexical_tag, LexicalTagType.ACR)
Exemple #14
0
    def test_update_supplemental_concept(self):
        """ Tests the update of a `SupplementalConcept` record via the `update`
            method of the `DalMesh` class.
        """

        # Create a `Supplemental` record as a fixture.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)

        # IODU a new `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        # Retrieve the new record.
        obj_original = self.dal.get(
            SupplementalConcept,
            obj_id,
        )  # type: SupplementalConcept

        # Assert that the different fields of the record match.
        self.assertEqual(obj_original.supplemental_concept_id, obj_id)
        self.assertEqual(obj_original.supplemental_id, supplemental_id)
        self.assertEqual(obj_original.concept_id, concept_id)
        self.assertEqual(obj_original.is_preferred, True)

        # Update the record.
        self.dal.update_attr_value(
            SupplementalConcept,
            obj_id,
            "is_preferred",
            False,
        )

        # Retrieve the updated record.
        obj_updated = self.dal.get(
            SupplementalConcept,
            obj_id,
        )  # type: SupplementalConcept

        # Assert that the ID remained the same.
        self.assertEqual(obj_updated.supplemental_concept_id, 1)
        # Assert that attribute changed.
        self.assertEqual(obj_updated.is_preferred, False)
Exemple #15
0
    def test_delete_concept(self):
        """ Tests the deletion of a `Concept` record via the `delete` method of
            the `DalMesh` class.
        """

        # Create a new `Concept` record.
        obj_id, refr = create_concept(dal=self.dal)

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(Concept, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(Concept, obj_id)  # type: Concept

        self.assertIsNone(obj)
Exemple #16
0
    def test_update_concept(self):
        """ Tests the update of a `Concept` record via the `update` method of
            the `DalMesh` class.
        """

        # Create a new `Concept` record.
        obj_id, refr = create_concept(dal=self.dal)

        # Retrieve the new record.
        obj_original = self.dal.get(Concept, obj_id)  # type: Concept

        # Assert that the different fields of the record match.
        self.assertEqual(obj_original.concept_id, obj_id)
        self.assertEqual(obj_original.ui, refr["ui"])
        self.assertEqual(obj_original.name, refr["name"])
        self.assertEqual(obj_original.casn1_name, refr["casn1_name"])
        self.assertEqual(obj_original.registry_number, refr["registry_number"])
        self.assertEqual(obj_original.scope_note, refr["scope_note"])
        self.assertEqual(
            obj_original.translators_english_scope_note,
            refr["translators_english_scope_note"],
        )
        self.assertEqual(
            obj_original.translators_scope_note,
            refr["translators_scope_note"],
        )

        # Update the record.
        self.dal.update_attr_value(
            Concept,
            obj_id,
            "scope_note",
            "New scope note",
        )

        # Retrieve the updated record.
        obj_updated = self.dal.get(Concept, obj_id)  # type: Concept

        # Assert that the ID remained the same.
        self.assertEqual(obj_updated.concept_id, 1)
        # Assert that attribute changed.
        self.assertEqual(obj_updated.scope_note, "New scope note")
Exemple #17
0
    def test_iodu_concept_related_concept_duplicate(self):
        """ Tests the IODU insertion of duplicate `ConceptRelatedConcept`
            records to ensure deduplication functions as intended.
        """

        # Create three `Concept` records as fixtures.
        concept_01_id, _ = create_concept(dal=self.dal, ui="UI1", name="name1")
        concept_02_id, _ = create_concept(dal=self.dal, ui="UI2", name="name2")
        concept_03_id, _ = create_concept(dal=self.dal, ui="UI3", name="name3")

        # IODI a new `ConceptRelatedConcept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.BRD,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `ConceptRelatedConcept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.BRD,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `ConceptRelatedConcept` record with a changed
        # `relation_name` field which should trigger an update on the existing
        # record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_02_id,
            relation_name=RelationNameType.NRW,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(
            ConceptRelatedConcept,
            obj_id,
        )  # type: ConceptRelatedConcept

        self.assertEqual(obj.relation_name, RelationNameType.NRW)

        # IODU a new `Concept` record.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_03_id,
            relation_name=RelationNameType.REL,
        )

        self.assertEqual(obj_id, 4)

        # IODU the same `Concept` record as before.
        obj_id = self.dal.iodu_concept_related_concept(
            concept_id=concept_01_id,
            related_concept_id=concept_03_id,
            relation_name=RelationNameType.REL,
        )

        self.assertEqual(obj_id, 4)
    def test_iodu_concept_term_duplicate(self):
        """ Tests the IODU insertion of duplicate `ConceptTerm` records to
            ensure deduplication functions as intended.
        """

        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)
        # Create a `Term` record as a fixture.
        term_id, _ = create_term(dal=self.dal)
        # Create a second`Term` record as a fixture.
        term_02_id, _ = create_term(dal=self.dal, ui="UI2", name="Name2")

        # IODU a new `ConceptTerm` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABB,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `ConceptTerm` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABB,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `ConceptTerm` record with a changed `lexical_tag` field
        # which should trigger an update on the existing record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABX,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(ConceptTerm, obj_id)  # type: ConceptTerm

        self.assertEqual(obj.lexical_tag, LexicalTagType.ABX)

        # IODU a new `Concept` record.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_02_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABX,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 4)

        # IODU the same `Concept` record as before.
        obj_id = self.dal.iodu_concept_term(
            concept_id=concept_id,
            term_id=term_02_id,
            is_concept_preferred_term=True,
            is_permuted_term=False,
            lexical_tag=LexicalTagType.ABX,
            is_record_preferred_term=True,
        )

        self.assertEqual(obj_id, 4)
Exemple #19
0
    def test_iodu_supplemental_concept(self):
        """ Tests the IODU insertion of duplicate `SupplementalConcept` records
            to ensure deduplication functions as intended.
        """

        # Create a `Supplemental` record as a fixture.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        # Create a `Concept` record as a fixture.
        concept_id, _ = create_concept(dal=self.dal)
        # Create a second `Concept` record as a fixture.
        concept_02_id, _ = create_concept(dal=self.dal, ui="UI2", name="Name2")

        # IODU a new `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `SupplementalConcept` record with a changed
        # `is_preferred` field which should trigger an update on the existing
        # record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_id,
            is_preferred=False,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(
            SupplementalConcept,
            obj_id,
        )  # type: SupplementalConcept

        self.assertEqual(obj.is_preferred, False)

        # IODU a new `SupplementalConcept` record.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_02_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 4)

        # IODU the same `SupplementalConcept` record as before.
        obj_id = self.dal.iodu_supplemental_concept(
            supplemental_id=supplemental_id,
            concept_id=concept_02_id,
            is_preferred=True,
        )

        self.assertEqual(obj_id, 4)