Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ManagedOpportunity return to Fixture #419

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading