예제 #1
0
    def test_asset_create_noasset(self):
        data = {'title': 'Bad Asset',
                'foobar': 'http://www.youtube.com/abcdefghi'}

        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        with self.assertRaises(AssertionError):
            view = AssetCreateView()
            view.request = request
            view.post(request)
예제 #2
0
    def test_asset_create_via_bookmarklet(self):
        data = {'title': 'YouTube Asset',
                'youtube': 'http://www.youtube.com/abcdefghi',
                'asset-source': 'bookmarklet'}

        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        view = AssetCreateView()
        view.request = request
        response = view.post(request)

        self.assertEquals(response.status_code, 200)

        Asset.objects.get(title='YouTube Asset')
예제 #3
0
    def test_sources_from_args(self):
        data = {
            'title': 'Bad Asset',
            'asset-source': 'bookmarklet',
            'image': 'x' * 5000,  # too long
            'url': 'https://www.youtube.com/abcdefghi'
        }
        request = RequestFactory().post('/save/', data)
        sources = AssetCreateView.sources_from_args(request)

        self.assertEquals(len(sources.keys()), 0)

        data = {
            'title': 'Good Asset',
            'asset-source': 'bookmarklet',
            'image': 'https://www.flickr.com/',
            'image-metadata': ['w720h526;text/html']
        }
        request = RequestFactory().post('/save/', data)
        sources = AssetCreateView.sources_from_args(request)
        self.assertEquals(len(sources.keys()), 2)
        self.assertEquals(sources['image'].url, 'https://www.flickr.com/')
        self.assertTrue(sources['image'].primary)
        self.assertEquals(sources['image'].width, 720)
        self.assertEquals(sources['image'].height, 526)
        self.assertEquals(sources['image'].media_type, 'text/html')

        data = {
            'title': 'HTML5 video title',
            'asset-source': 'bookmarklet',
            'video': 'http://www.example.com/video.mp4',
            'video-metadata': 'w480h358',
            'metadata-description': 'Video description',
        }
        request = RequestFactory().post('/save/', data)
        sources = AssetCreateView.sources_from_args(request)
        self.assertEquals(len(sources.keys()), 2)
        self.assertEquals(sources['video'].url,
                          'http://www.example.com/video.mp4')
        self.assertTrue(sources['video'].primary)
        self.assertEquals(sources['video'].width, 480)
        self.assertEquals(sources['video'].height, 358)
예제 #4
0
    def test_parse_user(self):
        view = AssetCreateView()
        request = RequestFactory().get('/')
        request.course = self.sample_course

        # regular path
        request.user = self.student_one
        self.assertEquals(view.parse_user(request), self.student_one)

        # "as" without permissions
        request = RequestFactory().get('/', {'as': self.student_two.username})
        request.user = self.student_one
        request.course = self.sample_course
        self.assertEquals(view.parse_user(request), self.student_one)

        # "as" with permissions
        request.user = UserFactory(is_staff=True)
        request.course = self.sample_course
        self.add_as_faculty(request.course, request.user)
        self.assertEquals(view.parse_user(request), self.student_two)
예제 #5
0
    def test_parse_user(self):
        view = AssetCreateView()
        request = RequestFactory().get('/')
        request.course = self.sample_course

        # regular path
        request.user = self.student_one
        self.assertEquals(view.parse_user(request), self.student_one)

        # "as" without permissions
        request = RequestFactory().get('/', {'as': self.student_two.username})
        request.user = self.student_one
        request.course = self.sample_course
        self.assertEquals(view.parse_user(request), self.student_one)

        # "as" with permissions
        request.user = UserFactory(is_staff=True)
        request.course = self.sample_course
        self.add_as_faculty(request.course, request.user)
        self.assertEquals(view.parse_user(request), self.student_two)
예제 #6
0
    def test_asset_create_via_bookmarklet(self):
        data = {'title': 'YouTube Asset',
                'youtube': 'http://www.youtube.com/abcdefghi',
                'asset-source': 'bookmarklet'}

        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        view = AssetCreateView()
        view.request = request
        response = view.post(request)

        self.assertEquals(response.status_code, 200)
        Asset.objects.get(title='YouTube Asset')

        data = {
            'title': 'HTML5 video title',
            'asset-source': 'bookmarklet',
            'video': 'http://www.example.com/video.mp4',
            'video-metadata': 'w480h358',
            'metadata-description': 'Video description',
        }
        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        view = AssetCreateView()
        view.request = request
        response = view.post(request)

        self.assertEquals(response.status_code, 200)
        asset = Asset.objects.get(title='HTML5 video title')
        self.assertEquals(asset.metadata()['description'],
                          [data['metadata-description']])
예제 #7
0
    def test_sources_from_args(self):
        data = {'title': 'Bad Asset',
                'asset-source': 'bookmarklet',
                'image': 'x' * 5000,  # too long
                'url': 'http://www.youtube.com/abcdefghi'}
        request = RequestFactory().post('/save/', data)
        sources = AssetCreateView.sources_from_args(request)

        self.assertEquals(len(sources.keys()), 0)

        data = {'title': 'Good Asset',
                'asset-source': 'bookmarklet',
                'image': 'http://www.flickr.com/',
                'image-metadata': [u'w720h526;text/html']}
        request = RequestFactory().post('/save/', data)
        sources = AssetCreateView.sources_from_args(request)
        self.assertEquals(len(sources.keys()), 2)
        self.assertEquals(sources['image'].url, 'http://www.flickr.com/')
        self.assertTrue(sources['image'].primary)
        self.assertEquals(sources['image'].width, 720)
        self.assertEquals(sources['image'].height, 526)
        self.assertEquals(sources['image'].media_type, 'text/html')
예제 #8
0
    def test_asset_create_via_bookmarklet(self):
        data = {
            'title': 'YouTube Asset',
            'youtube': 'https://www.youtube.com/abcdefghi',
            'asset-source': 'bookmarklet'
        }

        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        view = AssetCreateView()
        view.request = request
        response = view.post(request)

        self.assertEquals(response.status_code, 200)
        Asset.objects.get(title='YouTube Asset')

        data = {
            'title': 'HTML5 video title',
            'asset-source': 'bookmarklet',
            'video': 'http://www.example.com/video.mp4',
            'video-metadata': 'w480h358',
            'metadata-description': 'Video description',
        }
        request = RequestFactory().post('/save/', data)
        request.user = self.instructor_one
        request.course = self.sample_course

        view = AssetCreateView()
        view.request = request
        response = view.post(request)

        self.assertEquals(response.status_code, 200)
        asset = Asset.objects.get(title='HTML5 video title')
        self.assertEquals(asset.metadata()['description'],
                          [data['metadata-description']])
예제 #9
0
        }),

    # Composition Space
    path('project/', include('mediathread.projects.urls')),

    # Instructor Dashboard
    path('course/<int:course_pk>/dashboard/settings/',
         InstructorDashboardSettingsView.as_view(),
         name='course-settings-general'),

    # Reporting
    path('course/<int:course_pk>/reports/',
         include('mediathread.reports.urls')),

    # Bookmarklet, Wardenclyffe, Staff custom asset entry
    path('save/', AssetCreateView.as_view(), name='asset-save'),
    path('update/', AssetUpdateView.as_view(), name='asset-update-view'),
    path('setting/<slug:user_name>/', set_user_setting),
    path('stats/', TemplateView.as_view(template_name='stats.html')),
    path('smoketest/', include('smoketest.urls')),
    path('course/<int:course_pk>/taxonomy/',
         include('mediathread.taxonomy.urls')),
    path('lti/', include('lti_auth.urls')),

    # Public To World Access ###
    path('s/<slug:context_slug>/<slug:obj_type>/<int:obj_id>/',
         ProjectPublicView.as_view(),
         name='collaboration-obj-view'),
]

if settings.DEBUG:
예제 #10
0
파일: urls.py 프로젝트: ccnmtl/mediathread
             os.path.join(os.path.dirname(admin.__file__), 'media')),
         'show_indexes': True}),

    # Composition Space
    url(r'^project/', include('mediathread.projects.urls')),

    # Instructor Dashboard
    url(r'^dashboard/settings/$',
        InstructorDashboardSettingsView.as_view(),
        name='course-settings-general'),

    # Reporting
    url(r'^reports/', include('mediathread.reports.urls')),

    # Bookmarklet, Wardenclyffe, Staff custom asset entry
    url(r'^save/$', AssetCreateView.as_view(), name='asset-save'),
    url(r'^update/$', AssetUpdateView.as_view(), name='asset-update-view'),

    url(r'^setting/(?P<user_name>\w[^/]*)/$', set_user_setting),

    url(r'^stats/', TemplateView.as_view(template_name='stats.html')),
    url(r'^smoketest/', include('smoketest.urls')),

    url(r'^taxonomy/', include('mediathread.taxonomy.urls')),

    url(r'^lti/', include('lti_auth.urls')),

    url(r'^test/clear/', ClearTestCache.as_view()),

    # Public To World Access ###
    url(r'^s/(?P<context_slug>\w+)/(?P<obj_type>\w+)/(?P<obj_id>\d+)/',
예제 #11
0
            True
        }),

    # Composition Space
    url(r'^project/', include('mediathread.projects.urls')),

    # Instructor Dashboard
    url(r'^dashboard/settings/$',
        InstructorDashboardSettingsView.as_view(),
        name='course-settings-general'),

    # Reporting
    url(r'^reports/', include('mediathread.reports.urls')),

    # Bookmarklet, Wardenclyffe, Staff custom asset entry
    url(r'^save/$', AssetCreateView.as_view(), name='asset-save'),
    url(r'^update/$', AssetUpdateView.as_view(), name='asset-update-view'),
    url(r'^setting/(?P<user_name>\w[^/]*)/$', set_user_setting),
    url(r'^stats/', TemplateView.as_view(template_name='stats.html')),
    url(r'^smoketest/', include('smoketest.urls')),
    url(r'^taxonomy/', include('mediathread.taxonomy.urls')),
    url(r'^lti/', include('lti_auth.urls')),
    url(r'^test/clear/', ClearTestCache.as_view()),

    # Public To World Access ###
    url(r'^s/(?P<context_slug>\w+)/(?P<obj_type>\w+)/(?P<obj_id>\d+)/',
        ProjectPublicView.as_view(),
        name='collaboration-obj-view'),
]

if settings.DEBUG: