Skip to content

Commit

Permalink
Fix tests with extra PUs
Browse files Browse the repository at this point in the history
  • Loading branch information
sravfeyn committed Jan 10, 2025
1 parent 0268bb0 commit e67cbce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions commcare_connect/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ def paymentunit_options():


@pytest.fixture
def mobile_user_with_connect_link(db, opportunity, paymentunit_options) -> User:
def num_paymentunits():
# let tests parametrize as needed
return 2


@pytest.fixture
def mobile_user_with_connect_link(db, opportunity, paymentunit_options, num_paymentunits) -> User:
user = MobileUserFactory()
access = OpportunityAccessFactory(user=user, opportunity=opportunity, accepted=True)
claim = OpportunityClaimFactory(end_date=opportunity.end_date, opportunity_access=access)
payment_units = PaymentUnitFactory.create_batch(
2, opportunity=opportunity, parent_payment_unit=None, **(paymentunit_options)
num_paymentunits, opportunity=opportunity, parent_payment_unit=None, **(paymentunit_options)
)
budget_per_user = sum([p.max_total * p.amount for p in payment_units])
opportunity.total_budget = budget_per_user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def test_form_receiver_assessment(
).exists()


@pytest.mark.parametrize("num_paymentunits", [1])
@pytest.mark.django_db
def test_receiver_deliver_form(mobile_user_with_connect_link: User, api_client: APIClient, opportunity: Opportunity):
deliver_unit = DeliverUnitFactory(app=opportunity.deliver_app, payment_unit=opportunity.paymentunit_set.first())
Expand Down Expand Up @@ -542,6 +543,7 @@ def test_receiver_verification_flags_catchment_areas(
assert ["catchment", "Visit outside worker catchment areas"] in visit.flag_reason.get("flags", [])


@pytest.mark.parametrize("num_paymentunits", [1])
@pytest.mark.parametrize("opportunity", [{"opp_options": {"managed": True, "org_pay_per_visit": 2}}], indirect=True)
@pytest.mark.parametrize(
"visit_status, review_status",
Expand All @@ -565,6 +567,7 @@ def test_receiver_visit_review_status(
assert visit.review_status == review_status


@pytest.mark.parametrize("num_paymentunits", [1])
@pytest.mark.parametrize(
"opportunity, paymentunit_options, visit_status",
[
Expand Down

0 comments on commit e67cbce

Please sign in to comment.