Skip to content

Commit

Permalink
Fix tests for combined import statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
pxwxnvermx committed Nov 19, 2024
1 parent 3f885ff commit 9ead2c7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions commcare_connect/opportunity/tests/test_visit_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_bulk_update_visit_status(opportunity: Opportunity, mobile_user: User):
import_status = _bulk_update_visit_status(opportunity, dataset)
after_update = now()

assert not import_status.missing_visits
assert not import_status.missing

updated_visits = UserVisit.objects.filter(opportunity=opportunity)
for visit in updated_visits:
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_bulk_update_reason(opportunity: Opportunity, mobile_user: User):
dataset = Dataset(headers=["visit id", "status", "rejected reason"])
dataset.extend([[visit.xform_id, VisitValidationStatus.rejected.value, reason]])
import_status = _bulk_update_visit_status(opportunity, dataset)
assert not import_status.missing_visits
assert not import_status.missing
visit.refresh_from_db()
assert visit.status == VisitValidationStatus.rejected
assert visit.reason == reason
Expand Down Expand Up @@ -290,8 +290,8 @@ def test_bulk_update_payments(opportunity: Opportunity):
dataset.append((mobile_user.username, mobile_user.phone_number, mobile_user.name, 50))

payment_import_status = _bulk_update_payments(opportunity, dataset)
assert payment_import_status.seen_users == {user.username for user in mobile_user_seen}
assert payment_import_status.missing_users == {user.username for user in mobile_user_missing}
assert payment_import_status.seen == {user.username for user in mobile_user_seen}
assert payment_import_status.missing == {user.username for user in mobile_user_missing}
assert Payment.objects.filter(opportunity_access__opportunity=opportunity).count() == 5
for access in access_objects:
payment = Payment.objects.get(opportunity_access=access)
Expand Down Expand Up @@ -369,10 +369,8 @@ def test_bulk_update_catchments(opportunity, dataset, new_catchments, old_catchm

import_status = _bulk_update_catchments(opportunity, dataset)

assert import_status.seen_catchments == {
str(catchment.id) for catchment in old_catchments
}, "Mismatch in updated catchments"
assert import_status.new_catchments == len(new_catchments), "Incorrect number of new catchments"
assert import_status.seen == {str(catchment.id) for catchment in old_catchments}, "Mismatch in updated catchments"
assert len(import_status.missing) == len(new_catchments), "Incorrect number of new catchments"

for catchment in old_catchments:
updated_catchment = CatchmentArea.objects.get(site_code=catchment.site_code)
Expand Down Expand Up @@ -555,7 +553,7 @@ def test_network_manager_flagged_visit_review_status(mobile_user: User, opportun
before_update = now()
import_status = _bulk_update_visit_status(opportunity, dataset)
after_update = now()
assert not import_status.missing_visits
assert not import_status.missing
updated_visits = UserVisit.objects.filter(opportunity=opportunity)
for visit in updated_visits:
assert visit.status == visit_status
Expand Down

0 comments on commit 9ead2c7

Please sign in to comment.