Skip to content

Commit

Permalink
add test for learn progress
Browse files Browse the repository at this point in the history
  • Loading branch information
calellowitz committed Oct 11, 2023
1 parent 612f9a5 commit ea9fb1e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions commcare_connect/opportunity/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ class OpportunityAccessFactory(DjangoModelFactory):

class Meta:
model = "opportunity.OpportunityAccess"


class CompletedModuleFactory(DjangoModelFactory):
opportunity = SubFactory(OpportunityFactory)
user = SubFactory("commcare_connect.users.tests.factories.UserFactory")
date = Faker("date")
module = SubFactory(LearnModuleFactory, app=SelfAttribute("..opportunity.learn_app"))
duration = Faker("time_delta")

class Meta:
model = "opportunity.CompletedModule"
12 changes: 12 additions & 0 deletions commcare_connect/opportunity/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

from commcare_connect.opportunity.tests.factories import CompletedModuleFactory, OpportunityAccessFactory


@pytest.mark.django_db
def test_learn_progress():
module = CompletedModuleFactory()
access_1 = OpportunityAccessFactory(opportunity=module.opportunity, user=module.user)
access_2 = OpportunityAccessFactory(opportunity=module.opportunity)
assert access_1.learn_progress == 100
assert access_2.learn_progress == 0

0 comments on commit ea9fb1e

Please sign in to comment.