Add program enrollment status option: ended
We'd like to add this status to help distinguish between learners who've graduated from the program and learners who warranted some sort of removal from the program. JIRA:EDUCATOR-4702
This commit is contained in:
@@ -90,6 +90,7 @@ class ProgramEnrollmentReadingTests(TestCase):
|
||||
(cls.user_3, cls.ext_3, cls.program_uuid_y, cls.curriculum_uuid_c, PEStatuses.CANCELED), # 7
|
||||
(None, cls.ext_4, cls.program_uuid_y, cls.curriculum_uuid_c, PEStatuses.ENROLLED), # 8
|
||||
(cls.user_1, None, cls.program_uuid_x, cls.curriculum_uuid_b, PEStatuses.SUSPENDED), # 9
|
||||
(cls.user_2, None, cls.program_uuid_y, cls.curriculum_uuid_c, PEStatuses.ENDED), # 10
|
||||
]
|
||||
for user, external_user_key, program_uuid, curriculum_uuid, status in enrollment_test_data:
|
||||
ProgramEnrollmentFactory(
|
||||
@@ -148,6 +149,7 @@ class ProgramEnrollmentReadingTests(TestCase):
|
||||
# Specifying no curriculum (because ext_6 only has Program Y
|
||||
# enrollments in one curriculum, so it's not ambiguous).
|
||||
(program_uuid_y, None, None, ext_6, 6),
|
||||
(program_uuid_y, None, username_2, None, 10),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_get_program_enrollment(
|
||||
|
||||
@@ -1,12 +1,75 @@
|
||||
"""
|
||||
(Future home of) Tests for program enrollment writing Python API.
|
||||
Tests for program enrollment writing Python API.
|
||||
|
||||
Currently, we do not directly unit test the functions in api/writing.py.
|
||||
Currently, we do not directly unit test the functions in api/writing.py extensively.
|
||||
This is okay for now because they are all used in
|
||||
`rest_api.v1.views` and is thus tested through `rest_api.v1.tests.test_views`.
|
||||
Eventually it would be good to directly test the Python API function and just use
|
||||
mocks in the view tests.
|
||||
This file serves as a placeholder and reminder to do that the next time there
|
||||
is development on the program_enrollments writing API.
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from organizations.tests.factories import OrganizationFactory
|
||||
from django.core.cache import cache
|
||||
|
||||
from lms.djangoapps.program_enrollments.constants import ProgramEnrollmentStatuses as PEStatuses
|
||||
from lms.djangoapps.program_enrollments.models import ProgramEnrollment
|
||||
from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL
|
||||
from openedx.core.djangoapps.catalog.tests.factories import OrganizationFactory as CatalogOrganizationFactory
|
||||
from openedx.core.djangoapps.catalog.tests.factories import ProgramFactory
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
from third_party_auth.tests.factories import SAMLProviderConfigFactory
|
||||
|
||||
from ..writing import (
|
||||
write_program_enrollments
|
||||
)
|
||||
|
||||
|
||||
class WritingProgramEnrollmentTest(CacheIsolationTestCase):
|
||||
"""
|
||||
Test cases for program enrollment writing functions.
|
||||
"""
|
||||
ENABLED_CACHES = ['default']
|
||||
|
||||
organization_key = 'test'
|
||||
|
||||
program_uuid_x = UUID('dddddddd-5f48-493d-9910-84e1d36c657f')
|
||||
|
||||
curriculum_uuid_a = UUID('aaaaaaaa-bd26-4370-94b8-b4063858210b')
|
||||
|
||||
user_0 = 'user-0'
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up test data
|
||||
"""
|
||||
super(WritingProgramEnrollmentTest, self).setUp()
|
||||
catalog_org = CatalogOrganizationFactory.create(key=self.organization_key)
|
||||
program = ProgramFactory.create(
|
||||
uuid=self.program_uuid_x,
|
||||
authoring_organizations=[catalog_org]
|
||||
)
|
||||
organization = OrganizationFactory.create(short_name=self.organization_key)
|
||||
SAMLProviderConfigFactory.create(organization=organization)
|
||||
cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid_x), program, None)
|
||||
|
||||
def test_write_program_enrollments_status_ended(self):
|
||||
"""
|
||||
Successfully updates program enrollment to status ended if requested
|
||||
"""
|
||||
assert ProgramEnrollment.objects.count() == 0
|
||||
write_program_enrollments(self.program_uuid_x, [{
|
||||
'external_user_key': self.user_0,
|
||||
'status': PEStatuses.PENDING,
|
||||
'curriculum_uuid': self.curriculum_uuid_a,
|
||||
}], True, False)
|
||||
assert ProgramEnrollment.objects.count() == 1
|
||||
write_program_enrollments(self.program_uuid_x, [{
|
||||
'external_user_key': self.user_0,
|
||||
'status': PEStatuses.ENDED,
|
||||
'curriculum_uuid': self.curriculum_uuid_a,
|
||||
}], False, True)
|
||||
assert ProgramEnrollment.objects.count() == 1
|
||||
assert ProgramEnrollment.objects.filter(status=PEStatuses.ENDED).exists()
|
||||
|
||||
Reference in New Issue
Block a user