diff --git a/commcare_connect/conftest.py b/commcare_connect/conftest.py index 415a6bba..c984262b 100644 --- a/commcare_connect/conftest.py +++ b/commcare_connect/conftest.py @@ -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, @@ -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 diff --git a/commcare_connect/form_receiver/tests/test_receiver_integration.py b/commcare_connect/form_receiver/tests/test_receiver_integration.py index e1e601f6..e24857da 100644 --- a/commcare_connect/form_receiver/tests/test_receiver_integration.py +++ b/commcare_connect/form_receiver/tests/test_receiver_integration.py @@ -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", [ @@ -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):