def test_fetch_about_attribute(self, attribute_name): attribute_value = 'test_value' with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): CourseDetails.update_about_item(self.course, attribute_name, attribute_value, self.user.id) assert CourseDetails.fetch_about_attribute( self.course.id, attribute_name) == attribute_value
def test_fetch_about_attribute_error(self): attribute_name = 'not_an_about_attribute' with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): CourseDetails.update_about_item(self.course, attribute_name, 'test_value', self.user.id) with pytest.raises(ValueError): CourseDetails.fetch_about_attribute(self.course.id, attribute_name)
def test_changes_on_webview(self): # Prepare attributes to check for CourseDetails.update_about_item(self.course, 'short_description', 'Edraak Test Description', self.user.id) # Creating a certificate self._add_course_certificates(count=1, signatory_count=2) self._create_edraak_test_template() test_url = get_certificate_url(user_id=self.user.id, course_id=unicode(self.course.id)) # Getting certificate as HTML response = self.client.get(test_url) # Verifying contents self.assertContains(response, 'Edraak Template') self.assertContains(response, 'course_description: Edraak Test Description')
def test_updates_values_in_mongo_should_be_updated_in_sql(self): """ Test that a already existing course is correctly updated by update_course management command. """ mongo_course = CourseFactory.create(short_description='test') # short_description field is required by FUN Course model CourseDetails.update_about_item( mongo_course, 'short_description', u"Short description", None) self.assertFalse(FUNCourse.objects.all().exists()) call_command('update_courses', course_id=unicode(mongo_course.id)) self.assertTrue(u"Short description", FUNCourse.objects.get(key=mongo_course.id).short_description) CourseDetails.update_about_item( mongo_course, 'short_description', u"Short description changed", None) call_command('update_courses', course_id=unicode(mongo_course.id)) self.assertEqual( u"Short description changed", FUNCourse.objects.get(key=mongo_course.id).short_description)
def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() cls.course_without_about = CourseFactory.create( catalog_visibility=CATALOG_VISIBILITY_NONE) cls.course_with_about = CourseFactory.create( catalog_visibility=CATALOG_VISIBILITY_ABOUT) cls.purchase_course = CourseFactory.create( org='MITx', number='buyme', display_name='Course To Buy') CourseDetails.update_about_item(cls.course, 'overview', 'OOGIE BLOOGIE', None) CourseDetails.update_about_item(cls.course_without_about, 'overview', 'WITHOUT ABOUT', None) CourseDetails.update_about_item(cls.course_with_about, 'overview', 'WITH ABOUT', None)
def test_fetch_about_attribute_error(self): attribute_name = 'not_an_about_attribute' with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): CourseDetails.update_about_item(self.course, attribute_name, 'test_value', self.user.id) with self.assertRaises(ValueError): CourseDetails.fetch_about_attribute(self.course.id, attribute_name)
def test_fetch_about_attribute(self, attribute_name): attribute_value = 'test_value' with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): CourseDetails.update_about_item(self.course, attribute_name, attribute_value, self.user.id) self.assertEqual(CourseDetails.fetch_about_attribute(self.course.id, attribute_name), attribute_value)
def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create( metadata={"max_student_enrollments_allowed": 1}) CourseDetails.update_about_item(cls.course, 'overview', 'OOGIE BLOOGIE', None)
def test_fetch_effort(self): effort_value = 'test_hours_of_effort' with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): CourseDetails.update_about_item(self.course, 'effort', effort_value, self.user.id) self.assertEqual(CourseDetails.fetch_effort(self.course.id), effort_value)