Remove course_id field from CourseMode.

Handle this change appropriately in CourseModeFactory.
This commit is contained in:
Diana Huang
2020-04-03 11:31:49 -04:00
parent 09d814f7fd
commit 99863aebff
9 changed files with 69 additions and 55 deletions

View File

@@ -675,7 +675,7 @@ class CertificateGenerationEnabledTest(EventTestMixin, TestCase):
self.assertEqual(expect_enabled, actual_enabled)
class GenerateExampleCertificatesTest(TestCase):
class GenerateExampleCertificatesTest(ModuleStoreTestCase):
"""Test generation of example certificates. """
COURSE_KEY = CourseLocator(org='test', course='test', run='test')
@@ -739,7 +739,7 @@ class GenerateExampleCertificatesTest(TestCase):
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
class CertificatesBrandingTest(TestCase):
class CertificatesBrandingTest(ModuleStoreTestCase):
"""Test certificates branding. """
COURSE_KEY = CourseLocator(org='test', course='test', run='test')

View File

@@ -836,35 +836,6 @@ class ViewsTestCase(BaseViewsTestCase):
self.assertNotContains(response, str(course.id))
@patch.object(CourseOverview, 'load_from_module_store', return_value=None)
def test_financial_assistance_form_missing_course_overview(self, _mock_course_overview):
"""
Verify that learners can not get financial aid for the courses with no
course overview.
"""
# Create course
course = CourseFactory.create().id
# Create Course Modes
CourseModeFactory.create(mode_slug=CourseMode.AUDIT, course_id=course)
CourseModeFactory.create(mode_slug=CourseMode.VERIFIED, course_id=course)
# Enroll user in the course
# Don't use the CourseEnrollmentFactory since it ensures a CourseOverview is available
enrollment = CourseEnrollment.objects.create(
course_id=course,
user=self.user,
mode=CourseMode.AUDIT,
)
self.assertEqual(enrollment.course_overview, None)
url = reverse('financial_assistance_form')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, str(course))
def test_financial_assistance_form(self):
"""Verify that learner can get the financial aid for the course in which
he/she is enrolled in audit mode whereas the course provide verified mode.

View File

@@ -11,6 +11,7 @@ from django.urls import reverse
from six import text_type
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from shoppingcart.models import Coupon, CourseRegistrationCode
from student.roles import CourseFinanceAdminRole
@@ -39,7 +40,7 @@ class TestECommerceDashboardViews(SiteMixin, SharedModuleStoreTestCase):
# Create instructor account
self.instructor = AdminFactory.create()
self.client.login(username=self.instructor.username, password="test")
mode = CourseMode(
mode = CourseModeFactory(
course_id=text_type(self.course.id), mode_slug='honor',
mode_display_name='honor', min_price=10, currency='usd'
)
@@ -118,7 +119,7 @@ class TestECommerceDashboardViews(SiteMixin, SharedModuleStoreTestCase):
price = 200
# course B
course2 = CourseFactory.create(org='EDX', display_name='test_course', number='100')
mode = CourseMode(
mode = CourseModeFactory(
course_id=text_type(course2.id), mode_slug='honor',
mode_display_name='honor', min_price=30, currency='usd'
)
@@ -365,7 +366,7 @@ class TestECommerceDashboardViews(SiteMixin, SharedModuleStoreTestCase):
# Change honor mode to verified.
original_mode = CourseMode.objects.get(course_id=self.course.id, mode_slug='honor')
original_mode.delete()
new_mode = CourseMode(
new_mode = CourseModeFactory(
course_id=six.text_type(self.course.id), mode_slug='verified',
mode_display_name='verified', min_price=10, currency='usd'
)

View File

@@ -1271,7 +1271,8 @@ class TestCheckoutWithEcommerceService(ModuleStoreTestCase):
ecommerce api, we correctly call to that api to create a basket.
"""
user = UserFactory.create(username="test-username")
course_mode = CourseModeFactory.create(sku="test-sku").to_tuple()
course_id = 'edX/test/test_run'
course_mode = CourseModeFactory.create(course_id=course_id, sku="test-sku").to_tuple()
expected_payment_data = {'foo': 'bar'}
# mock out the payment processors endpoint
httpretty.register_uri(