From 7b268a2daf288fec1163d7f2322c4eb7575da78d Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 10 Jul 2018 16:39:26 +0530 Subject: Imporve download course offline views test to check files inside zip file --- yaksh/test_views.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'yaksh/test_views.py') diff --git a/yaksh/test_views.py b/yaksh/test_views.py index c1511c0..e691140 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -2049,9 +2049,18 @@ class TestCourses(TestCase): ) course_name = self.user1_course.name.replace(" ", "_") self.assertEqual(response.status_code, 200) - self.assertEqual(response.get('Content-Disposition'), - 'attachment; filename={0}.zip'.format(course_name) - ) + zip_file = string_io(response.content) + zipped_file = zipfile.ZipFile(zip_file, 'r') + self.assertIsNone(zipped_file.testzip()) + files_in_zip = zipped_file.namelist() + module_path = os.path.join(course_name, "demo_module", + "demo_module.html") + lesson_path = os.path.join(course_name, "demo_module", "demo_lesson", + "demo_lesson.html") + self.assertIn(module_path, files_in_zip) + self.assertIn(lesson_path, files_in_zip) + zip_file.close() + zipped_file.close() self.user1_course.learning_module.remove(self.learning_module1) -- cgit