From 3e62c5e29ae2ce29db80b227604cfef067d7ec54 Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Tue, 10 Sep 2013 09:54:27 -0400 Subject: [PATCH] Cleaner tests --- common/lib/xmodule/xmodule/seq_module.py | 2 +- .../lib/xmodule/xmodule/tests/test_import.py | 24 ++++++------------- .../chapter/handout_container.xml | 3 --- .../data/test_unicode/chapter/poll_test.xml | 7 ------ .../test_unicode/chapter/secret/magic.xml | 3 --- .../data/test_unicode/chapter/simple_html.xml | 8 +++++++ .../data/test_unicode/course/2012_Fall.xml | 16 ++----------- .../test/data/test_unicode/info/handouts.html | 1 - .../data/test_unicode/policies/2012_Fall.json | 14 ++--------- .../static/handouts/sample_handout.txt | 0 .../test_unicode/static/sample_static.txt | 0 .../static_import/∫hould_be_imπorted.html | 1 - .../test/data/test_unicode/tabs/syllabus.html | 1 - .../test/data/test_unicode/video/a_video.xml | 1 - 14 files changed, 20 insertions(+), 61 deletions(-) delete mode 100644 common/test/data/test_unicode/chapter/handout_container.xml delete mode 100644 common/test/data/test_unicode/chapter/poll_test.xml delete mode 100644 common/test/data/test_unicode/chapter/secret/magic.xml create mode 100644 common/test/data/test_unicode/chapter/simple_html.xml delete mode 100644 common/test/data/test_unicode/info/handouts.html delete mode 100644 common/test/data/test_unicode/static/handouts/sample_handout.txt delete mode 100644 common/test/data/test_unicode/static/sample_static.txt delete mode 100644 common/test/data/test_unicode/static_import/∫hould_be_imπorted.html delete mode 100644 common/test/data/test_unicode/tabs/syllabus.html delete mode 100644 common/test/data/test_unicode/video/a_video.xml diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index ebd49d75cf..867eae19ce 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -133,7 +133,7 @@ class SequenceDescriptor(SequenceFields, MakoModuleDescriptor, XmlDescriptor): except Exception as e: log.exception("Unable to load child when parsing Sequence. Continuing...") if system.error_tracker is not None: - system.error_tracker("ERROR: " + str(e)) + system.error_tracker("ERROR: " + unicode(e)) continue return {}, children diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 3c841aab50..387e9db88b 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -380,32 +380,22 @@ class ImportTestCase(BaseCourseTestCase): courses = modulestore.get_courses() self.assertEquals(len(courses), 1) course = courses[0] - course_id = course.id print("course errors:") # Expect to find an error/exception about characters in "®esources" - found = False expect = "Invalid characters in '®esources'" - for (msg, err) in modulestore.get_item_errors(course.location): - msg_u = msg.encode("utf-8") - err_u = err.encode("utf-8") - print(msg_u) - print(err_u) - if max(msg_u.find(expect), err_u.find(expect)) >= 1: - found = True + errors = [(msg.encode("utf-8"), err.encode("utf-8")) + for msg, err in + modulestore.get_item_errors(course.location)] - self.assertTrue(found) + self.assertTrue(any(expect in msg or expect in err + for msg, err in errors)) chapters = course.get_children() - self.assertEquals(len(chapters), 5) + self.assertEqual(len(chapters), 3) - ch2 = chapters[1] - self.assertEquals(ch2.url_name, "secret:magic") + ch3 = chapters[2] - print("Ch2 location: ", ch2.location) - - also_ch2 = modulestore.get_instance(course_id, ch2.location) - self.assertEquals(ch2, also_ch2) def test_url_name_mangling(self): """ diff --git a/common/test/data/test_unicode/chapter/handout_container.xml b/common/test/data/test_unicode/chapter/handout_container.xml deleted file mode 100644 index 0be4e30bbb..0000000000 --- a/common/test/data/test_unicode/chapter/handout_container.xml +++ /dev/null @@ -1,3 +0,0 @@ - - handouts - \ No newline at end of file diff --git a/common/test/data/test_unicode/chapter/poll_test.xml b/common/test/data/test_unicode/chapter/poll_test.xml deleted file mode 100644 index bbb340e936..0000000000 --- a/common/test/data/test_unicode/chapter/poll_test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - -

Have you changed your mind?

- Yes - No -
-
\ No newline at end of file diff --git a/common/test/data/test_unicode/chapter/secret/magic.xml b/common/test/data/test_unicode/chapter/secret/magic.xml deleted file mode 100644 index fe7adb7967..0000000000 --- a/common/test/data/test_unicode/chapter/secret/magic.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/common/test/data/test_unicode/chapter/simple_html.xml b/common/test/data/test_unicode/chapter/simple_html.xml new file mode 100644 index 0000000000..c07cf4a7c7 --- /dev/null +++ b/common/test/data/test_unicode/chapter/simple_html.xml @@ -0,0 +1,8 @@ + + + +

This is upside down text:

+

˙ʇxəʇ uʍop əpısdn sı sıɥʇ

+ +
+
diff --git a/common/test/data/test_unicode/course/2012_Fall.xml b/common/test/data/test_unicode/course/2012_Fall.xml index 4eb9d66171..b402922bcb 100644 --- a/common/test/data/test_unicode/course/2012_Fall.xml +++ b/common/test/data/test_unicode/course/2012_Fall.xml @@ -1,20 +1,8 @@ - - - - - - - - - - + + - diff --git a/common/test/data/test_unicode/info/handouts.html b/common/test/data/test_unicode/info/handouts.html deleted file mode 100644 index 85fa34d71d..0000000000 --- a/common/test/data/test_unicode/info/handouts.html +++ /dev/null @@ -1 +0,0 @@ -Sample \ No newline at end of file diff --git a/common/test/data/test_unicode/policies/2012_Fall.json b/common/test/data/test_unicode/policies/2012_Fall.json index c35877b8f5..71f88849ec 100644 --- a/common/test/data/test_unicode/policies/2012_Fall.json +++ b/common/test/data/test_unicode/policies/2012_Fall.json @@ -2,13 +2,13 @@ "course/2012_Fall": { "graceperiod": "2 days 5 hours 59 minutes 59 seconds", "start": "2015-07-17T12:00", - "display_name": "Toy Course", + "display_name": "Üñîçø∂e †es† Course", "graded": "true", "tabs": [ {"type": "courseware"}, {"type": "course_info", "name": "Course Info"}, {"type": "static_tab", "url_slug": "syllabus", "name": "ßyllabus"}, - {"type": "static_tab", "url_slug": "resources", "name": "Resources"}, + {"type": "static_tab", "url_slug": "resources", "name": "®esources"}, {"type": "discussion", "name": "∂iscussion"}, {"type": "wiki", "name": "∑iki"}, {"type": "progress", "name": "πrogress"} @@ -17,16 +17,6 @@ "chapter/Overview": { "display_name": "O√erview" }, - "videosequence/Toy_Videos": { - "display_name": "†oy Videos", - "format": "Lecture Sequence" - }, - "html/secret:toylab": { - "display_name": "Toy lab" - }, - "video/Video_Resources": { - "display_name": "Video Resources" - }, "video/Welcome": { "display_name": "Welcome" } diff --git a/common/test/data/test_unicode/static/handouts/sample_handout.txt b/common/test/data/test_unicode/static/handouts/sample_handout.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/common/test/data/test_unicode/static/sample_static.txt b/common/test/data/test_unicode/static/sample_static.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/common/test/data/test_unicode/static_import/∫hould_be_imπorted.html b/common/test/data/test_unicode/static_import/∫hould_be_imπorted.html deleted file mode 100644 index 2ab33a3a03..0000000000 --- a/common/test/data/test_unicode/static_import/∫hould_be_imπorted.html +++ /dev/null @@ -1 +0,0 @@ -

this ƒîlë should be in the contentstore

diff --git a/common/test/data/test_unicode/tabs/syllabus.html b/common/test/data/test_unicode/tabs/syllabus.html deleted file mode 100644 index 45c2a7fc8f..0000000000 --- a/common/test/data/test_unicode/tabs/syllabus.html +++ /dev/null @@ -1 +0,0 @@ -

This is a syllabus

diff --git a/common/test/data/test_unicode/video/a_video.xml b/common/test/data/test_unicode/video/a_video.xml deleted file mode 100644 index b90ea9d8c4..0000000000 --- a/common/test/data/test_unicode/video/a_video.xml +++ /dev/null @@ -1 +0,0 @@ -