Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def test_delete_supplemental_source(self):
        """ Tests the deletion of a `SupplementalSource` record via the `delete`
            method of the `DalMesh` class.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        source_id, _ = create_source(dal=self.dal)

        # IODI a new `SupplementalSource` record.
        obj_id = self.dal.iodi_supplemental_source(
            supplemental_id=supplemental_id,
            source_id=source_id,
        )

        self.assertEqual(obj_id, 1)

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

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

        self.assertIsNone(obj)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def test_delete_supplemental_pharmacological_action_descriptor(self):
        """ Tests the deletion of a
            `SupplementalPharmacologicalActionDescriptor` record via the
            `delete` method of the `DalMesh` class.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        descriptor_id, _ = create_descriptor(dal=self.dal)

        # IODI a new `SupplementalPharmacologicalActionDescriptor` record.
        obj_id = self.dal.iodi_supplemental_pharmacological_action_descriptor(
            supplemental_id=supplemental_id,
            pharmacological_action_descriptor_id=descriptor_id,
        )

        self.assertEqual(obj_id, 1)

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

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

        self.assertIsNone(obj)
    def test_delete_supplemental_previous_indexing(self):
        """ Tests the deletion of a `SupplementalPreviousIndexing` record via
            the `delete` method of the `DalMesh` class.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        previous_indexing_id, _ = create_previous_indexing(dal=self.dal)

        # IODI a new `SupplementalPreviousIndexing` record.
        obj_id = self.dal.iodi_supplemental_previous_indexing(
            supplemental_id=supplemental_id,
            previous_indexing_id=previous_indexing_id,
        )

        self.assertEqual(obj_id, 1)

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

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

        self.assertIsNone(obj)
Exemplo n.º 7
0
    def test_iodi_get_supplemental_source(self):
        """ Tests the IODI insertion of a `SupplementalSource` record via the
            `iodi_supplemental_source` method of the `DalMesh` class and its
            retrieval via the `get` method.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        source_id, _ = create_source(dal=self.dal)

        # IODI a new `SupplementalSource` record.
        obj_id = self.dal.iodi_supplemental_source(
            supplemental_id=supplemental_id,
            source_id=source_id,
        )

        self.assertEqual(obj_id, 1)

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

        # Assert that the different fields of the record match.
        self.assertEqual(obj.supplemental_source_id, 1)
        self.assertEqual(obj.supplemental_id, supplemental_id)
        self.assertEqual(obj.source_id, source_id)
Exemplo n.º 8
0
    def test_iodi_get_supplemental_pharmacological_action_descriptor(self):
        """ Tests the IODI insertion of a
            `SupplementalPharmacologicalActionDescriptor` record via the
            `iodi_supplemental_pharmacological_action_descriptor` method of the
            `DalMesh` class and its retrieval via the `get` method.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        descriptor_id, _ = create_descriptor(dal=self.dal)

        # IODI a new `SupplementalPharmacologicalActionDescriptor` record.
        obj_id = self.dal.iodi_supplemental_pharmacological_action_descriptor(
            supplemental_id=supplemental_id,
            pharmacological_action_descriptor_id=descriptor_id,
        )

        self.assertEqual(obj_id, 1)

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

        # Assert that the different fields of the record match.
        self.assertEqual(
            obj.supplemental_pharmacological_action_descriptor_id,
            1,
        )
        self.assertEqual(obj.supplemental_id, supplemental_id)
        self.assertEqual(
            obj.pharmacological_action_descriptor_id,
            descriptor_id,
        )
    def test_iodi_get_supplemental_previous_indexing(self):
        """ Tests the IODI insertion of a `SupplementalPreviousIndexing` record
            via the `iodi_supplemental_previous_indexing` method of the
            `DalMesh` class and its retrieval via the `get` method.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        previous_indexing_id, _ = create_previous_indexing(dal=self.dal)

        # IODI a new `SupplementalPreviousIndexing` record.
        obj_id = self.dal.iodi_supplemental_previous_indexing(
            supplemental_id=supplemental_id,
            previous_indexing_id=previous_indexing_id,
        )

        self.assertEqual(obj_id, 1)

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

        # Assert that the different fields of the record match.
        self.assertEqual(obj.supplemental_previous_indexing_id, 1)
        self.assertEqual(obj.supplemental_id, supplemental_id)
        self.assertEqual(obj.previous_indexing_id, previous_indexing_id)
Exemplo n.º 10
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)
    def test_update_supplemental(self):
        """ Tests the update of a `Supplemental` record via the `update` method
            of the `DalMesh` class.
        """

        # Create a new `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal)

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

        # Assert that the different fields of the record match.
        self.assertEqual(obj_original.supplemental_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.note, refr["note"])
        self.assertEqual(obj_original.frequency, refr["frequency"])

        # Update the record.
        self.dal.update_attr_value(
            Supplemental,
            obj_id,
            "note",
            "different note",
        )

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

        # Assert that the ID remained the same.
        self.assertEqual(obj_updated.supplemental_id, 1)
        # Assert that attribute changed.
        self.assertEqual(obj_updated.note, "different note")
Exemplo n.º 12
0
    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_iodu_supplemental_duplicate(self):
        """ Tests the IODU insertion of duplicate `Supplemental` records to
            ensure deduplication functions as intended.
        """

        # Create a new `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal)

        self.assertEqual(obj_id, 1)

        # IODU the same `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal)

        self.assertEqual(obj_id, 1)

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

        self.assertEqual(obj_id, 1)

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

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

        # IODU a new `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal,
                                           ui="C000003",
                                           name="NewSupplemental")

        self.assertEqual(obj_id, 4)

        # IODU the same `Supplemental` record as before.
        obj_id, refr = create_supplemental(dal=self.dal,
                                           ui="C000003",
                                           name="NewSupplemental")

        self.assertEqual(obj_id, 4)
Exemplo n.º 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)
    def test_delete_supplemental(self):
        """ Tests the deletion of a `Supplemental` record via the `delete`
            method of the `DalMesh` class.
        """

        # Create a new `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal)

        self.assertEqual(obj_id, 1)

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

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

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

        # Create a new `Supplemental` record.
        obj_id, refr = create_supplemental(dal=self.dal)

        self.assertEqual(obj_id, 1)

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

        # Assert that the different fields of the record match.
        self.assertEqual(obj.supplemental_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.note, refr["note"])
        self.assertEqual(obj.frequency, refr["frequency"])
Exemplo n.º 17
0
    def test_iodi_supplemental_pharmacological_action_descriptor_duplicate(
            self):
        """ Tests the IODI insertion of duplicate
            `SupplementalPharmacologicalActionDescriptor` records to ensure
            deduplication functions as intended.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        descriptor_id, _ = create_descriptor(dal=self.dal)
        descriptor_02_id, _ = create_descriptor(dal=self.dal,
                                                ui="UI2",
                                                name="NewDescriptor")

        # IODI a new `SupplementalPharmacologicalActionDescriptor` record.
        obj_id = self.dal.iodi_supplemental_pharmacological_action_descriptor(
            supplemental_id=supplemental_id,
            pharmacological_action_descriptor_id=descriptor_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI an identical `SupplementalPharmacologicalActionDescriptor`
        # record.
        obj_id = self.dal.iodi_supplemental_pharmacological_action_descriptor(
            supplemental_id=supplemental_id,
            pharmacological_action_descriptor_id=descriptor_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI a new `SupplementalPharmacologicalActionDescriptor` record.
        obj_id = self.dal.iodi_supplemental_pharmacological_action_descriptor(
            supplemental_id=supplemental_id,
            pharmacological_action_descriptor_id=descriptor_02_id,
        )

        self.assertEqual(obj_id, 3)
    def test_iodi_supplemental_previous_indexing_duplicate(self):
        """ Tests the IODI insertion of duplicate `SupplementalPreviousIndexing`
            records to ensure deduplication functions as intended.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        previous_indexing_id, _ = create_previous_indexing(dal=self.dal)
        previous_indexing_02_id, _ = create_previous_indexing(
            dal=self.dal,
            previous_indexing="NewPreviousIndexing"
        )

        # IODI a new `SupplementalPreviousIndexing` record.
        obj_id = self.dal.iodi_supplemental_previous_indexing(
            supplemental_id=supplemental_id,
            previous_indexing_id=previous_indexing_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI an identical `SupplementalPreviousIndexing` record.
        obj_id = self.dal.iodi_supplemental_previous_indexing(
            supplemental_id=supplemental_id,
            previous_indexing_id=previous_indexing_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI a new `SupplementalPreviousIndexing` record.
        obj_id = self.dal.iodi_supplemental_previous_indexing(
            supplemental_id=supplemental_id,
            previous_indexing_id=previous_indexing_02_id,
        )

        self.assertEqual(obj_id, 3)
Exemplo n.º 19
0
    def test_iodi_supplemental_source_duplicate(self):
        """ Tests the IODI insertion of duplicate `SupplementalSource` records
            to ensure deduplication functions as intended.
        """

        # Create fixture records.
        supplemental_id, _ = create_supplemental(dal=self.dal)
        source_id, _ = create_source(dal=self.dal)
        source_02_id, _ = create_source(
            dal=self.dal,
            source="Vopr Neirokhir 6:48;1977",
        )

        # IODI a new `SupplementalSource` record.
        obj_id = self.dal.iodi_supplemental_source(
            supplemental_id=supplemental_id,
            source_id=source_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI an identical `SupplementalSource` record.
        obj_id = self.dal.iodi_supplemental_source(
            supplemental_id=supplemental_id,
            source_id=source_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI a new `SupplementalSource` record.
        obj_id = self.dal.iodi_supplemental_source(
            supplemental_id=supplemental_id,
            source_id=source_02_id,
        )

        self.assertEqual(obj_id, 3)
Exemplo n.º 20
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)