From e171f22ecaa04805ea9b7af016cb02cc1debe497 Mon Sep 17 00:00:00 2001 From: Pawan Verma Date: Mon, 25 Nov 2024 14:00:19 +0530 Subject: [PATCH] Add opportunity date tests --- .../tests/test_receiver_integration.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/commcare_connect/form_receiver/tests/test_receiver_integration.py b/commcare_connect/form_receiver/tests/test_receiver_integration.py index 2757a57c..1c1f79ed 100644 --- a/commcare_connect/form_receiver/tests/test_receiver_integration.py +++ b/commcare_connect/form_receiver/tests/test_receiver_integration.py @@ -604,13 +604,20 @@ def test_receiver_visit_review_status( @pytest.mark.parametrize( - "paymentunit_options, visit_status", + "opportunity, paymentunit_options, visit_status", [ - ({"start_date": now().date()}, VisitValidationStatus.approved), - ({"start_date": now() + datetime.timedelta(days=2)}, VisitValidationStatus.trial), - ({"end_date": now().date()}, VisitValidationStatus.approved), - ({"end_date": now() - datetime.timedelta(days=2)}, VisitValidationStatus.over_limit), + ({}, {"start_date": now().date()}, VisitValidationStatus.approved), + ({}, {"start_date": now() + datetime.timedelta(days=2)}, VisitValidationStatus.trial), + ({}, {"end_date": now().date()}, VisitValidationStatus.approved), + ({}, {"end_date": now() - datetime.timedelta(days=2)}, VisitValidationStatus.over_limit), + ({"opp_options": {"start_date": now().date()}}, {}, VisitValidationStatus.approved), + ({"opp_options": {"start_date": now() + datetime.timedelta(days=2)}}, {}, VisitValidationStatus.trial), + ({"opp_options": {"end_date": now().date()}}, {}, VisitValidationStatus.approved), + # NOTE: this test case fails as opportunities with past end_date are marked + # as inactive, and are not processed in the form processor + # ({"opp_options": {"end_date": now() - datetime.timedelta(days=2)}}, {}, VisitValidationStatus.over_limit), ], + indirect=["opportunity"], ) def test_receiver_visit_payment_unit_dates( mobile_user_with_connect_link: User, api_client: APIClient, opportunity: Opportunity, visit_status