Esempio n. 1
0
    def test_get_selection(self):
        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        gann = SherdNoteFactory(
            asset=asset, author=self.instructor_one,
            title=None, range1=None, range2=None)
        note = SherdNoteFactory(asset=asset, author=self.instructor_one,
                                title='Selection')

        view = AssetEmbedListView()

        keys = ['foo-1234']
        self.assertIsNone(view.get_selection(keys, self.instructor_one))

        with self.assertRaises(Http404):
            keys = ['item-666']
            view.get_selection(keys, self.instructor_one)

        with self.assertRaises(Http404):
            keys = ['selection-666']
            view.get_selection(keys, self.instructor_one)

        keys = ['item-%s' % asset.id]
        view = AssetEmbedListView()
        self.assertEquals(view.get_selection(keys, self.instructor_one), gann)

        keys = ['selection-%s' % note.id]
        view = AssetEmbedListView()
        self.assertEquals(view.get_selection(keys, self.instructor_one), note)
Esempio n. 2
0
    def test_get_secret(self):
        secrets = {'http://testserver/': 'testing'}
        with self.settings(SERVER_ADMIN_SECRETKEYS=secrets):
            view = AssetEmbedListView()

            with self.assertRaises(Http404):
                view.get_secret('http://foo.bar')

            self.assertEquals(view.get_secret('http://testserver/a/b/c'),
                              'testing')
Esempio n. 3
0
    def test_get_dimensions_video(self):
        asset = AssetFactory.create(
            course=self.sample_course, primary_source='youtube')

        self.assertEquals(asset.media_type(), 'video')

        view = AssetEmbedListView()
        dims = view.get_dimensions(asset.primary)
        self.assertEquals(dims['width'], view.EMBED_VIDEO_WIDTH)
        self.assertEquals(dims['height'], view.EMBED_VIDEO_HEIGHT)
Esempio n. 4
0
    def test_get_secret(self):
        secrets = {'http://testserver/': 'testing'}
        with self.settings(SERVER_ADMIN_SECRETKEYS=secrets):
            view = AssetEmbedListView()

            with self.assertRaises(Http404):
                view.get_secret('http://foo.bar')

            self.assertEquals(view.get_secret('http://testserver/a/b/c'),
                              'testing')
Esempio n. 5
0
    def test_get_dimensions_video(self):
        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='youtube')

        self.assertEquals(asset.media_type(), 'video')

        view = AssetEmbedListView()
        dims = view.get_dimensions(asset.primary)
        self.assertEquals(dims['width'], EMBED_WIDTH)
        self.assertEquals(dims['height'], EMBED_HEIGHT)
Esempio n. 6
0
    def test_get_iframe_url(self):
        view = AssetEmbedListView()
        view.request = RequestFactory().get('/')
        view.request.course = self.sample_course

        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        note = SherdNoteFactory(asset=asset, author=self.instructor_one,
                                title='Selection')

        url = view.get_iframe_url('secret', note)
        prefix = 'http%3A%2F%2Ftestserver%2Fasset%2Fembed%2Fview%2F1%2F1%2F%3F'
        self.assertTrue(url.startswith(prefix))
        self.assertTrue('nonce' in url)
        self.assertTrue('hmac' in url)
Esempio n. 7
0
    def test_get_iframe_url(self):
        view = AssetEmbedListView()
        view.request = RequestFactory().get('/')
        view.request.course = self.sample_course

        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        note = SherdNoteFactory(asset=asset,
                                author=self.instructor_one,
                                title='Selection')

        url = view.get_iframe_url('secret', note)
        x = 'http%3A%2F%2Ftestserver%2Fasset%2Fembed%2Fview%2F{}%2F{}%2F%3F'
        prefix = x.format(self.sample_course.id, note.id)
        self.assertTrue(url.startswith(prefix))
        self.assertTrue('nonce' in url)
        self.assertTrue('hmac' in url)
Esempio n. 8
0
    def test_get_dimensions_image(self):
        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        primary = asset.primary

        view = AssetEmbedListView()
        dims = view.get_dimensions(primary)
        self.assertEquals(dims['width'], view.EMBED_IMAGE_WIDTH)
        self.assertEquals(dims['height'], view.EMBED_IMAGE_WIDTH)

        # set a width/height
        primary.width = 400
        primary.height = 600
        primary.save()

        dims = view.get_dimensions(primary)
        self.assertEquals(dims['width'], view.EMBED_IMAGE_WIDTH)
        self.assertEquals(dims['height'], 400)
Esempio n. 9
0
    def test_get_dimensions_image(self):
        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        primary = asset.primary

        view = AssetEmbedListView()
        dims = view.get_dimensions(primary)
        self.assertEquals(dims['width'], EMBED_WIDTH)
        self.assertEquals(dims['height'], EMBED_HEIGHT)

        # set a width/height
        primary.width = 400
        primary.height = 600
        primary.save()

        dims = view.get_dimensions(primary)
        self.assertEquals(dims['width'], EMBED_WIDTH)
        self.assertEquals(dims['height'], EMBED_HEIGHT)
Esempio n. 10
0
        'asset-view'),
    url(r'^(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        AssetWorkspaceView.as_view(), {}, 'annotation-view'),
    url(r'^create/(?P<asset_id>\d+)/annotations/$', annotation_create),

    # django-rest-framework
    url(r'^(?P<asset_id>\d+)/sherdnote/create/$',
        SherdNoteCreate.as_view(),
        name='sherdnote-create'),
    url(r'^create/(?P<asset_id>\d+)/global/$', annotation_create_global),
    url(r'^copy/(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        AnnotationCopyView.as_view(), {}, 'annotation-copy-view'),
    url(r'^save/(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        annotation_save,
        name="annotation-save"),
    url(r'^delete/(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        annotation_delete,
        name="annotation-delete"),
    url(r'^delete/(?P<asset_id>\d+)/$', asset_delete, name='asset-delete'),
    url(r'^xmeml/(?P<asset_id>\w+)/$',
        final_cut_pro_xml,
        name="final_cut_pro_xml"),
    url(r'^embed/view/(?P<course_id>\d+)/(?P<annot_id>\d+)/$',
        AssetEmbedView.as_view(), {}, 'selection-embed-view'),
    url(r'^embed', AssetEmbedListView.as_view(), {}, 'asset-embed-list'),
    url(r'scalar/', ScalarExportView.as_view(), name='scalar_export'),

    # Asset workspace variations
    url(r'^$', AssetWorkspaceView.as_view(), {}, 'asset-collection-view'),
]
Esempio n. 11
0
        AssetWorkspaceView.as_view(), {}, 'annotation-view'),

    url(r'^create/(?P<asset_id>\d+)/annotations/$', 'annotation_create'),

    url(r'^create/(?P<asset_id>\d+)/global/$', 'annotation_create_global'),

    url(r'^save/(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        'annotation_save',
        name="annotation-save"),

    url(r'^delete/(?P<asset_id>\d+)/annotations/(?P<annot_id>\d+)/$',
        'annotation_delete',
        name="annotation-delete"),

    url(r'^delete/(?P<asset_id>\d+)/$', 'asset_delete', name='asset-delete'),

    url(r'^xmeml/(?P<asset_id>\w+)/$',
        'final_cut_pro_xml',
        name="final_cut_pro_xml"),

    url(r'^embed/view/(?P<course_id>\d+)/(?P<annot_id>\d+)/$',
        AssetEmbedView.as_view(), {}, 'selection-embed-view'),

    url(r'^embed', AssetEmbedListView.as_view(), {}, 'asset-embed-list'),

    url(r'scalar/', ScalarExportView.as_view(), name='scalar_export'),

    # Asset workspace variations
    url(r'^$', AssetWorkspaceView.as_view(), {}, 'asset-collection-view'),
)
Esempio n. 12
0
    def test_get_selection(self):
        asset = AssetFactory.create(course=self.sample_course,
                                    primary_source='image',
                                    author=self.instructor_one)
        gann = SherdNoteFactory(asset=asset,
                                author=self.instructor_one,
                                title=None,
                                range1=None,
                                range2=None)
        note = SherdNoteFactory(asset=asset,
                                author=self.instructor_one,
                                title='Selection')

        view = AssetEmbedListView()

        keys = ['foo-1234']
        self.assertIsNone(view.get_selection(keys, self.instructor_one))

        with self.assertRaises(Http404):
            keys = ['item-666']
            view.get_selection(keys, self.instructor_one)

        with self.assertRaises(Http404):
            keys = ['selection-666']
            view.get_selection(keys, self.instructor_one)

        keys = ['item-%s' % asset.id]
        view = AssetEmbedListView()
        self.assertEquals(view.get_selection(keys, self.instructor_one), gann)

        keys = ['selection-%s' % note.id]
        view = AssetEmbedListView()
        self.assertEquals(view.get_selection(keys, self.instructor_one), note)
Esempio n. 13
0
    path('most_recent/', MostRecentView.as_view(), name='asset-most-recent'),
    path('<int:asset_id>/', AssetWorkspaceView.as_view(), {}, 'asset-view'),
    path('<int:asset_id>/annotations/<int:annot_id>/',
         AssetWorkspaceView.as_view(), {}, 'annotation-view'),
    path('create/<int:asset_id>/annotations/', annotation_create),

    # django-rest-framework
    path('<int:asset_id>/sherdnote/create/',
         SherdNoteCreate.as_view(),
         name='sherdnote-create'),
    path('<int:asset_id>/save/', AssetUpdate.as_view(), name='asset-update'),
    path('create/<int:asset_id>/global/', annotation_create_global),
    path('copy/<int:asset_id>/annotations/<int:annot_id>/',
         AnnotationCopyView.as_view(), {}, 'annotation-copy-view'),
    path('save/<int:asset_id>/annotations/<int:annot_id>/',
         annotation_save,
         name="annotation-save"),
    path('delete/<int:asset_id>/annotations/<int:annot_id>/',
         annotation_delete,
         name="annotation-delete"),
    path('delete/<int:asset_id>/', asset_delete, name='asset-delete'),
    path('xmeml/<int:asset_id>/', final_cut_pro_xml, name="final_cut_pro_xml"),
    path('embed/view/<int:course_id>/<int:annot_id>/',
         AssetEmbedView.as_view(), {}, 'selection-embed-view'),
    path('embed/', AssetEmbedListView.as_view(), {}, 'asset-embed-list'),
    path('scalar/', ScalarExportView.as_view(), name='scalar_export'),

    # Asset workspace variations
    path('', AssetWorkspaceView.as_view(), {}, 'asset-collection-view'),
]