From 161b11334d02d56b5475827f020c104a5cf55c60 Mon Sep 17 00:00:00 2001 From: Pawan Verma Date: Wed, 23 Oct 2024 15:52:31 +0530 Subject: [PATCH] Add combine receiver tests with parametrize --- .../tests/test_receiver_integration.py | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/commcare_connect/form_receiver/tests/test_receiver_integration.py b/commcare_connect/form_receiver/tests/test_receiver_integration.py index be002639..2d2a93a4 100644 --- a/commcare_connect/form_receiver/tests/test_receiver_integration.py +++ b/commcare_connect/form_receiver/tests/test_receiver_integration.py @@ -588,30 +588,21 @@ def test_receiver_verification_flags_catchment_areas( @pytest.mark.parametrize("opportunity", [{"managed": True}], indirect=True) -def test_receiver_auto_agree_approved_visit( - mobile_user_with_connect_link: User, api_client: APIClient, opportunity: Opportunity -): - assert opportunity.managed - form_json = get_form_json_for_payment_unit(opportunity.paymentunit_set.all()[0]) - make_request(api_client, form_json, mobile_user_with_connect_link) - visit = UserVisit.objects.get(user=mobile_user_with_connect_link) - assert not visit.flagged - assert visit.status == VisitValidationStatus.approved - assert visit.review_status == VisitReviewStatus.agree - - -@pytest.mark.parametrize("opportunity", [{"managed": True}], indirect=True) -def test_receiver_flagged_visit_review_pending( - mobile_user_with_connect_link: User, api_client: APIClient, opportunity: Opportunity +@pytest.mark.parametrize( + "visit_status, review_status", + [ + (VisitValidationStatus.approved, VisitReviewStatus.agree), + (VisitValidationStatus.pending, VisitReviewStatus.pending), + ], +) +def test_receiver_visit_review_status( + mobile_user_with_connect_link: User, api_client: APIClient, opportunity: Opportunity, visit_status, review_status ): assert opportunity.managed - form_json = get_form_json_for_payment_unit(opportunity.paymentunit_set.all()[0]) - form_json["metadata"]["location"] = None + form_json = get_form_json_for_payment_unit(opportunity.paymentunit_set.first()) + 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) - assert visit.flagged - assert visit.status == VisitValidationStatus.pending - assert visit.review_status == VisitReviewStatus.pending def get_form_json_for_payment_unit(payment_unit):