-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from dimagi/hy/total-visit-calculation-error
Total visit calculation not accounting for org pay, causing inflation in total visit count.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from commcare_connect.opportunity.tests.factories import PaymentUnitFactory | ||
from commcare_connect.program.models import ManagedOpportunity | ||
from commcare_connect.program.tests.factories import ManagedOpportunityFactory | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_managed_opportunity_stats(): | ||
opportunity = ManagedOpportunityFactory(total_budget=3600000, org_pay_per_visit=450) | ||
PaymentUnitFactory(opportunity=opportunity, max_total=600, max_daily=5, amount=750) | ||
|
||
opportunity = ManagedOpportunity.objects.get(id=opportunity.id) | ||
|
||
assert opportunity.budget_per_user == 450000 | ||
assert opportunity.allotted_visits == 3000 | ||
assert opportunity.number_of_users == 5 | ||
assert opportunity.max_visits_per_user_new == 600 | ||
assert opportunity.daily_max_visits_per_user_new == 5 | ||
assert opportunity.budget_per_visit_new == 750 |