diff --git a/common/djangoapps/contentserver/tests/test.py b/common/djangoapps/contentserver/tests/test.py index d084494be3..340092b4d3 100644 --- a/common/djangoapps/contentserver/tests/test.py +++ b/common/djangoapps/contentserver/tests/test.py @@ -45,31 +45,42 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): settings.MODULESTORE['default']['OPTIONS']['fs_root'] = path('common/test/data') settings.MODULESTORE['direct']['OPTIONS']['fs_root'] = path('common/test/data') - self.client = Client() - - loc = Location('c4x', 'edX', 'toy', 'asset', 'sample_static.txt' ) - self.loc = loc - - rel_url = StaticContent.get_url_path_from_location(loc) base = "http://127.0.0.1:8000" - + self.client = Client() self.contentstore = contentstore() + + # A locked the asset + loc = Location('c4x', 'edX', 'toy', 'asset', 'sample_static.txt' ) + self.loc = loc + rel_url = StaticContent.get_url_path_from_location(loc) + self.url = base + rel_url + + # An unlocked asset + loc2 = Location('c4x', 'edX', 'toy', 'asset', 'another_static.txt' ) + self.loc2 = loc2 + rel_url2 = StaticContent.get_url_path_from_location(loc2) + self.url2 = base + rel_url2 + + import_from_xml(modulestore('direct'), 'common/test/data/', ['toy'], static_content_store=self.contentstore, verbose=True) - self.url = base + rel_url + + self.contentstore.set_attr(self.loc, 'locked', True) + def tearDown(self): MongoClient().drop_database(TEST_DATA_CONTENTSTORE['OPTIONS']['db']) _CONTENTSTORE.clear() - def test_aunlocked_asset(self): + def test_unlocked_asset(self): """ Test that unlocked assets are being served. """ - # Unlock the asset - self.contentstore.set_attr(self.loc, 'locked', False) - resp = self.client.get(self.url) + # Logout user + self.client.logout() + + resp = self.client.get(self.url2) self.assertEqual(resp.status_code, 200) @@ -81,10 +92,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): (3) User is logged in and registered """ - # Lock the asset - self.contentstore.set_attr(self.loc, 'locked', True) - - # Case (1) resp = self.client.get(self.url) self.assertEqual(resp.status_code, 302) @@ -110,7 +117,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): # Case (3) # Enroll student course_id = "/".join([self.loc.org, self.loc.course, self.loc.name]) - self.assertTrue(CourseEnrollment.enroll(user, course_id)) + CourseEnrollment.enroll(user, course_id) self.assertTrue(CourseEnrollment.is_enrolled(user, course_id)) resp = self.client.get(self.url) diff --git a/common/test/data/toy/static/another_static.txt b/common/test/data/toy/static/another_static.txt new file mode 100644 index 0000000000..83e560736d --- /dev/null +++ b/common/test/data/toy/static/another_static.txt @@ -0,0 +1,17 @@ + + _ + | | + _____ ____ _ _ __ ___ _ __ | | ___ + / _ \ \/ / _` | '_ ` _ \| '_ \| |/ _ \ +| __/> < (_| | | | | | | |_) | | __/ + \___/_/\_\__,_|_| |_| |_| .__/|_|\___| + | | + |_| + _ _ _ + | | | | (_) + ___| |_ __ _| |_ _ ___ + / __| __/ _` | __| |/ __| + \__ \ || (_| | |_| | (__ + |___/\__\__,_|\__|_|\___| + +