Skip to content

Commit

Permalink
tests for get_orphaned_patients
Browse files Browse the repository at this point in the history
  • Loading branch information
m-goggins committed Feb 20, 2025
1 parent 55afb49 commit 08f433b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/database/test_mpi_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,3 +876,21 @@ def test_delete_persons(self, session):
assert session.query(models.Person).count() == 1
assert mpi_service.get_person_by_reference_id(session, person1.reference_id) is None
assert mpi_service.get_person_by_reference_id(session, person2.reference_id) == person2


class TestGetOrphanedPatients:
def test_get_orphaned_patients_success(self, session):
patient = models.Patient(person=None, data={"reference_id": str(uuid.uuid4())})
patient2 = models.Patient(person=models.Person(), data={})
session.add_all([patient, patient2])
session.flush()
assert session.query(models.Patient).count() == 2
assert session.query(models.Person).count() == 1
assert mpi_service.get_orphaned_patients(session) == [patient]

def test_get_orphaned_patients_no_patients(self, session):
person = models.Person()
patient = models.Patient(person=person, data={})
session.add(patient)
session.flush()
assert mpi_service.get_orphaned_patients(session) == []

0 comments on commit 08f433b

Please sign in to comment.