Skip to content

Commit

Permalink
Merge pull request openedx#467 from kawaguchi-ks/develop/cypress/add_…
Browse files Browse the repository at this point in the history
…feature_upload_course_list

Add feature upload_course_list (#164)
  • Loading branch information
kawaguchi-ks committed Dec 2, 2015
2 parents 235ce07 + 4cf5e09 commit 5ffeb98
Show file tree
Hide file tree
Showing 27 changed files with 1,795 additions and 4 deletions.
85 changes: 85 additions & 0 deletions cms/djangoapps/contentstore/tests/test_course_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ def test_virgin_fetch(self):
self.assertIsNone(details.end_date, "end date somehow initialized " + str(details.end_date))
self.assertIsNone(details.enrollment_start, "enrollment_start date somehow initialized " + str(details.enrollment_start))
self.assertIsNone(details.enrollment_end, "enrollment_end date somehow initialized " + str(details.enrollment_end))
self.assertIsNone(details.deadline_start, "deadline_start date somehow initialized " + str(details.deadline_start))
self.assertIsNone(details.terminate_start, "terminate_start date somehow initialized " + str(details.terminate_start))
self.assertIsNone(details.syllabus, "syllabus somehow initialized" + str(details.syllabus))
self.assertIsNone(details.intro_video, "intro_video somehow initialized" + str(details.intro_video))
self.assertIsNone(details.effort, "effort somehow initialized" + str(details.effort))
self.assertIsNone(details.language, "language somehow initialized" + str(details.language))
self.assertEqual(details.course_category, [])
self.assertFalse(details.is_f2f_course)
self.assertEqual(details.course_canonical_name, self.course.display_name)
self.assertEqual(details.course_contents_provider, "")
self.assertEqual(details.teacher_name, "Teacher")
self.assertEqual(details.course_span, "")

def test_encoder(self):
details = CourseDetails.fetch(self.course.id)
Expand All @@ -61,10 +69,18 @@ def test_encoder(self):
self.assertIsNone(jsondetails['end_date'], "end date somehow initialized ")
self.assertIsNone(jsondetails['enrollment_start'], "enrollment_start date somehow initialized ")
self.assertIsNone(jsondetails['enrollment_end'], "enrollment_end date somehow initialized ")
self.assertIsNone(jsondetails['deadline_start'], "deadline_start date somehow initialized ")
self.assertIsNone(jsondetails['terminate_start'], "terminate_start date somehow initialized ")
self.assertIsNone(jsondetails['syllabus'], "syllabus somehow initialized")
self.assertIsNone(jsondetails['intro_video'], "intro_video somehow initialized")
self.assertIsNone(jsondetails['effort'], "effort somehow initialized")
self.assertIsNone(jsondetails['language'], "language somehow initialized")
self.assertEqual(jsondetails['course_category'], [])
self.assertFalse(jsondetails['is_f2f_course'])
self.assertEqual(jsondetails['course_canonical_name'], self.course.display_name)
self.assertEqual(jsondetails['course_contents_provider'], "")
self.assertEqual(jsondetails['teacher_name'], "Teacher")
self.assertEqual(jsondetails['course_span'], "")

def test_ooc_encoder(self):
"""
Expand Down Expand Up @@ -124,6 +140,36 @@ def test_update_and_fetch(self):
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).language,
jsondetails.language
)
jsondetails.course_category = ["food", "teen"]
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).course_category,
jsondetails.course_category
)
jsondetails.is_f2f_course = True
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).is_f2f_course,
jsondetails.is_f2f_course
)
jsondetails.course_canonical_name = "After Course Canonical Name"
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).course_canonical_name,
jsondetails.course_canonical_name
)
jsondetails.course_contents_provider = "After Course Contents Provider"
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).course_contents_provider,
jsondetails.course_contents_provider
)
jsondetails.teacher_name = "After Teacher Name"
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).teacher_name,
jsondetails.teacher_name
)
jsondetails.course_span = "After Course Span"
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).course_span,
jsondetails.course_span
)

@override_settings(MKTG_URLS={'ROOT': 'dummy-root'})
def test_marketing_site_fetch(self):
Expand All @@ -148,6 +194,15 @@ def test_marketing_site_fetch(self):
self.assertNotContains(response, "Course Introduction Video")
self.assertNotContains(response, "Requirements")

self.assertContains(response, "Course Deadline Date")
self.assertContains(response, "Course Terminate Date")
self.assertContains(response, "Course Category")
self.assertContains(response, "Course Canonical Name")
self.assertContains(response, "Course Contents Provider")
self.assertContains(response, "Teacher Name")
self.assertContains(response, "Course Span")
self.assertContains(response, "Face 2 Face Classroom")

@unittest.skipUnless(settings.FEATURES.get('ENTRANCE_EXAMS', False), True)
def test_entrance_exam_created_updated_and_deleted_successfully(self):
seed_milestone_relationship_types()
Expand Down Expand Up @@ -275,6 +330,15 @@ def test_regular_site_fetch(self):
self.assertContains(response, "Course Introduction Video")
self.assertContains(response, "Requirements")

self.assertContains(response, "Course Deadline Date")
self.assertContains(response, "Course Terminate Date")
self.assertContains(response, "Course Category")
self.assertContains(response, "Course Canonical Name")
self.assertContains(response, "Course Contents Provider")
self.assertContains(response, "Teacher Name")
self.assertContains(response, "Course Span")
self.assertContains(response, "Face 2 Face Classroom")


class CourseDetailsViewTest(CourseTestCase):
"""
Expand All @@ -294,6 +358,8 @@ def alter_field(self, url, details, field, val):
payload['end_date'] = CourseDetailsViewTest.convert_datetime_to_iso(details.end_date)
payload['enrollment_start'] = CourseDetailsViewTest.convert_datetime_to_iso(details.enrollment_start)
payload['enrollment_end'] = CourseDetailsViewTest.convert_datetime_to_iso(details.enrollment_end)
payload['deadline_start'] = CourseDetailsViewTest.convert_datetime_to_iso(details.deadline_start)
payload['terminate_start'] = CourseDetailsViewTest.convert_datetime_to_iso(details.terminate_start)
resp = self.client.ajax_post(url, payload)
self.compare_details_with_encoding(json.loads(resp.content), details.__dict__, field + str(val))

Expand All @@ -319,13 +385,23 @@ def test_update_and_fetch(self):
self.alter_field(url, details, 'enrollment_start', datetime.datetime(2012, 10, 12, 1, 30, tzinfo=utc))

self.alter_field(url, details, 'enrollment_end', datetime.datetime(2012, 11, 15, 1, 30, tzinfo=utc))
self.alter_field(url, details, 'deadline_start', datetime.datetime(2012, 11, 18, 1, 30, tzinfo=utc))
self.alter_field(url, details, 'terminate_start', datetime.datetime(2013, 2, 13, 1, 30, tzinfo=utc))
self.alter_field(url, details, 'short_description', "Short Description")
self.alter_field(url, details, 'overview', "Overview")
self.alter_field(url, details, 'intro_video', "intro_video")
self.alter_field(url, details, 'effort', "effort")
self.alter_field(url, details, 'course_image_name', "course_image_name")
self.alter_field(url, details, 'language', "en")

self.alter_field(url, details, 'course_category', [])
self.alter_field(url, details, 'course_category', ["food", "teen"])
self.alter_field(url, details, 'is_f2f_course', True)
self.alter_field(url, details, 'course_canonical_name', "Course Canonical Name")
self.alter_field(url, details, 'course_contents_provider', "Course Contents Provider")
self.alter_field(url, details, 'teacher_name', "Teacher Name")
self.alter_field(url, details, 'course_span', "Course Span")

def compare_details_with_encoding(self, encoded, details, context):
"""
compare all of the fields of the before and after dicts
Expand All @@ -334,13 +410,22 @@ def compare_details_with_encoding(self, encoded, details, context):
self.compare_date_fields(details, encoded, context, 'end_date')
self.compare_date_fields(details, encoded, context, 'enrollment_start')
self.compare_date_fields(details, encoded, context, 'enrollment_end')
self.compare_date_fields(details, encoded, context, 'deadline_start')
self.compare_date_fields(details, encoded, context, 'terminate_start')
self.assertEqual(details['short_description'], encoded['short_description'], context + " short_description not ==")
self.assertEqual(details['overview'], encoded['overview'], context + " overviews not ==")
self.assertEqual(details['intro_video'], encoded.get('intro_video', None), context + " intro_video not ==")
self.assertEqual(details['effort'], encoded['effort'], context + " efforts not ==")
self.assertEqual(details['course_image_name'], encoded['course_image_name'], context + " images not ==")
self.assertEqual(details['language'], encoded['language'], context + " languages not ==")

self.assertEqual(details['course_category'], encoded['course_category'], context + " course_category not ==")
self.assertEqual(details['is_f2f_course'], encoded['is_f2f_course'], context + " is_f2f_course not ==")
self.assertEqual(details['course_canonical_name'], encoded['course_canonical_name'], context + " course_canonical_name not ==")
self.assertEqual(details['course_contents_provider'], encoded['course_contents_provider'], context + " course_contents_provider not ==")
self.assertEqual(details['teacher_name'], encoded['teacher_name'], context + " teacher_name not ==")
self.assertEqual(details['course_span'], encoded['course_span'], context + " course_span not ==")

def compare_date_fields(self, details, encoded, context, field):
"""
Compare the given date fields between the before and after doing json deserialization
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 5ffeb98

Please sign in to comment.