def test_map_into_course_asset_location(self):
     loc = AssetLocation('org', 'course', 'run', 'asset', 'foo.bar')
     course_key = SlashSeparatedCourseKey("edX", "toy", "2012_Fall")
     self.assertEquals(
         AssetLocation("edX", "toy", "2012_Fall", 'asset', 'foo.bar'),
         loc.map_into_course(course_key)
     )
Example #2
0
 def test_generate_thumbnail_image(self):
     contentStore = ContentStore()
     content = Content(
         AssetLocation(u'mitX', u'800', u'ignore_run', u'asset',
                       u'monsters__.jpg'), None)
     (thumbnail_content,
      thumbnail_file_location) = contentStore.generate_thumbnail(content)
     self.assertIsNone(thumbnail_content)
     self.assertEqual(
         AssetLocation(u'mitX', u'800', u'ignore_run', u'thumbnail',
                       u'monsters__.jpg'), thumbnail_file_location)
Example #3
0
 def test_compute_location(self):
     # We had a bug that __ got converted into a single _. Make sure that substitution of INVALID_CHARS (like space)
     # still happen.
     asset_location = StaticContent.compute_location(
         SlashSeparatedCourseKey('mitX', '400', 'ignore'),
         'subs__1eo_jXvZnE .srt.sjson')
     self.assertEqual(
         AssetLocation(u'mitX', u'400', u'ignore', u'asset',
                       u'subs__1eo_jXvZnE_.srt.sjson', None),
         asset_location)
Example #4
0
    def compute_location(course_key, path, revision=None, is_thumbnail=False):
        """
        Constructs a location object for static content.

        - course_key: the course that this asset belongs to
        - path: is the name of the static asset
        - revision: is the object's revision information
        - is_tumbnail: is whether or not we want the thumbnail version of this
            asset
        """
        path = path.replace('/', '_')
        return AssetLocation(course_key.org, course_key.course, course_key.run,
                             'asset' if not is_thumbnail else 'thumbnail',
                             AssetLocation.clean_keeping_underscores(path),
                             revision)
Example #5
0
 def test_get_location_from_path(self):
     asset_location = StaticContent.get_location_from_path(
         u'/c4x/foo/bar/asset/images_course_image.jpg')
     self.assertEqual(
         AssetLocation(u'foo', u'bar', None, u'asset',
                       u'images_course_image.jpg', None), asset_location)