Merge pull request #23583 from edx/feanil/test_propert_removal

WIP Remove the course_id property on student.CourseEnrollment.
This commit is contained in:
Feanil Patel
2020-04-06 10:13:10 -04:00
committed by GitHub
8 changed files with 38 additions and 30 deletions

View File

@@ -592,7 +592,7 @@ class TestSessionEntitlement(CatalogIntegrationMixin, TestCase):
course_overview = CourseOverviewFactory.create(id=course_key, start=self.tomorrow)
CourseModeFactory.create(mode_slug=CourseMode.VERIFIED, min_price=100, course_id=course_overview.id)
course_enrollment = CourseEnrollmentFactory(
user=self.user, course_id=six.text_type(course_overview.id), mode=CourseMode.VERIFIED
user=self.user, course=course_overview, mode=CourseMode.VERIFIED
)
entitlement = CourseEntitlementFactory(
user=self.user, enrollment_course_run=course_enrollment, mode=CourseMode.VERIFIED
@@ -617,7 +617,7 @@ class TestSessionEntitlement(CatalogIntegrationMixin, TestCase):
expiration_datetime=now() - timedelta(days=1)
)
course_enrollment = CourseEnrollmentFactory(
user=self.user, course_id=six.text_type(course_overview.id), mode=CourseMode.VERIFIED
user=self.user, course=course_overview, mode=CourseMode.VERIFIED
)
entitlement = CourseEntitlementFactory(
user=self.user, enrollment_course_run=course_enrollment, mode=CourseMode.VERIFIED
@@ -643,7 +643,7 @@ class TestSessionEntitlement(CatalogIntegrationMixin, TestCase):
expiration_datetime=now() - timedelta(days=1)
)
course_enrollment = CourseEnrollmentFactory(
user=self.user, course_id=six.text_type(course_overview.id), mode=CourseMode.VERIFIED
user=self.user, course=course_overview, mode=CourseMode.VERIFIED
)
entitlement = CourseEntitlementFactory(
user=self.user, enrollment_course_run=course_enrollment, mode=CourseMode.VERIFIED

View File

@@ -27,7 +27,7 @@ from openedx.core.djangoapps.enrollments.errors import (
from openedx.core.djangoapps.enrollments.serializers import CourseEnrollmentSerializer
from openedx.core.lib.exceptions import CourseNotFoundError
from student.models import AlreadyEnrolledError, CourseEnrollment, CourseFullError, EnrollmentClosedError
from student.tests.factories import CourseAccessRoleFactory, UserFactory
from student.tests.factories import CourseAccessRoleFactory, UserFactory, CourseEnrollmentFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@@ -145,12 +145,15 @@ class EnrollmentDataTest(ModuleStoreTestCase):
# not exist in database) for the user and check that the method
# 'get_course_enrollments' ignores course enrollments for invalid
# or deleted courses
CourseEnrollment.objects.create(
non_existent_course_id = 'InvalidOrg/InvalidCourse/InvalidRun'
enrollement = CourseEnrollmentFactory.create(
user=self.user,
course_id='InvalidOrg/InvalidCourse/InvalidRun',
course_id=non_existent_course_id,
mode='honor',
is_active=True
)
enrollement.course.delete()
updated_results = data.get_course_enrollments(self.user.username)
self.assertEqual(results, updated_results)

View File

@@ -12,7 +12,7 @@ from openedx.core.djangoapps.catalog.tests.factories import (
CourseFactory,
ProgramFactory,
)
from student.tests.factories import TEST_PASSWORD, UserFactory
from student.tests.factories import TEST_PASSWORD, UserFactory, CourseEnrollmentFactory
from openedx.core.djangoapps.catalog.cache import (
CATALOG_COURSE_PROGRAMS_CACHE_KEY_TPL,
COURSE_PROGRAMS_CACHE_KEY_TPL,
@@ -93,7 +93,7 @@ class MicrobachelorsExternalIDTest(ModuleStoreTestCase, CacheIsolationTestCase):
course_run_key = self.program['courses'][0]['course_runs'][0]['key']
# Enroll user
enrollment = CourseEnrollment.objects.create(
enrollment = CourseEnrollmentFactory.create(
course_id=course_run_key,
user=self.user,
mode=CourseMode.VERIFIED,
@@ -110,7 +110,7 @@ class MicrobachelorsExternalIDTest(ModuleStoreTestCase, CacheIsolationTestCase):
course_run_key2 = self.program['courses'][1]['course_runs'][0]['key']
# Enroll user
CourseEnrollment.objects.create(
CourseEnrollmentFactory.create(
course_id=course_run_key1,
user=self.user,
mode=CourseMode.VERIFIED,
@@ -122,7 +122,7 @@ class MicrobachelorsExternalIDTest(ModuleStoreTestCase, CacheIsolationTestCase):
assert external_id.external_id_type.name == ExternalIdType.MICROBACHELORS_COACHING
original_external_user_uuid = external_id.external_user_id
CourseEnrollment.objects.create(
CourseEnrollmentFactory.create(
course_id=course_run_key2,
user=self.user,
mode=CourseMode.VERIFIED,