Skip to content

Commit

Permalink
Merge pull request #419 from dimagi/pkv/fix-tests-for-managed-opps
Browse files Browse the repository at this point in the history
Add ManagedOpportunity return to Fixture
  • Loading branch information
pxwxnvermx authored Oct 29, 2024
2 parents 578720a + b389826 commit 1581a47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion commcare_connect/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PaymentUnitFactory,
)
from commcare_connect.organization.models import Organization
from commcare_connect.program.tests.factories import ManagedOpportunityFactory
from commcare_connect.users.models import User
from commcare_connect.users.tests.factories import (
ConnectIdUserLinkFactory,
Expand Down Expand Up @@ -52,7 +53,10 @@ def opportunity(request):
verification_flags = getattr(request, "param", {}).get("verification_flags", {})
opp_options = {"is_test": False}
opp_options.update(getattr(request, "param", {}).get("opp_options", {}))
factory = OpportunityFactory(**opp_options)
if opp_options.get("managed", False):
factory = ManagedOpportunityFactory(**opp_options)
else:
factory = OpportunityFactory(**opp_options)
OpportunityVerificationFlagsFactory(opportunity=factory, **verification_flags)
return factory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def test_receiver_verification_flags_catchment_areas(
assert ["catchment", "Visit outside worker catchment areas"] in visit.flag_reason.get("flags", [])


@pytest.mark.parametrize("opportunity", [{"opp_options": {"managed": True}}], indirect=True)
@pytest.mark.parametrize("opportunity", [{"opp_options": {"managed": True, "org_pay_per_visit": 2}}], indirect=True)
@pytest.mark.parametrize(
"visit_status, review_status",
[
Expand All @@ -595,6 +595,11 @@ def test_receiver_visit_review_status(
if visit_status != VisitValidationStatus.approved:
form_json["metadata"]["location"] = None
make_request(api_client, form_json, mobile_user_with_connect_link)
visit = UserVisit.objects.get(user=mobile_user_with_connect_link)
if visit_status != VisitValidationStatus.approved:
assert visit.flagged
assert visit.status == visit_status
assert visit.review_status == review_status


def get_form_json_for_payment_unit(payment_unit):
Expand Down

0 comments on commit 1581a47

Please sign in to comment.