本文整理汇总了Python中mediathread.factories.AssetFactory类的典型用法代码示例。如果您正苦于以下问题:Python AssetFactory类的具体用法?Python AssetFactory怎么用?Python AssetFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssetFactory类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.setup_sample_course()
self.setup_alternate_course()
# Sample Course Image Asset
self.faculty_asset = AssetFactory.create(course=self.sample_course,
author=self.instructor_one,
primary_source='image')
self.student_asset = AssetFactory.create(course=self.sample_course,
author=self.student_one,
primary_source='image')
self.student_note1 = SherdNoteFactory(
asset=self.faculty_asset, author=self.student_one,
tags=',image1', body='student note on student asset')
self.student_note2 = SherdNoteFactory(
asset=self.student_asset, author=self.student_one,
tags=',image2', body='student note on faculty asset')
self.faculty_note1 = SherdNoteFactory(
asset=self.faculty_asset, author=self.instructor_one,
tags=',image3', body='faculty note on faculty asset')
self.faculty_note2 = SherdNoteFactory(
asset=self.student_asset, author=self.instructor_one,
tags=',image4', body='faculty note on student asset')
self.alt_asset = AssetFactory.create(course=self.alt_course,
author=self.alt_student,
primary_source='image')
self.alt_note = SherdNoteFactory(
asset=self.alt_asset, author=self.alt_student,
tags=',image1', body='student note on student asset')
self.faculty_composition = ProjectFactory.create(
course=self.sample_course, author=self.instructor_one,
policy='InstructorShared')
self.student_composition = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='CourseProtected')
self.assignment = ProjectFactory.create(
course=self.sample_course, author=self.instructor_one,
policy='CourseProtected', project_type='assignment')
self.assignment_response = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='PrivateEditorsAreOwners', parent=self.assignment)
self.alt_composition = ProjectFactory.create(
course=self.alt_course, author=self.student_one,
policy='CourseProtected')
self.discussion = self.create_discussion(
self.sample_course, self.instructor_one)
self.comment = self.add_comment(self.discussion, self.student_one)
self.alt_discussion = self.create_discussion(
self.alt_course, self.alt_instructor)
self.alt_comment = self.add_comment(self.alt_discussion,
self.alt_student)
self.superuser = UserFactory(is_superuser=True, is_staff=True)
self.add_as_faculty(self.sample_course, self.superuser)
开发者ID:c0cky,项目名称:mediathread,代码行数:60,代码来源:test_views.py
示例2: test_update_reference_in_string
def test_update_reference_in_string(self):
old_asset = AssetFactory(course=self.sample_course, author=self.student_one)
old_note = SherdNoteFactory(asset=old_asset, author=self.student_one, title="Selection", range1=43, range2=75)
alt_note = SherdNoteFactory(
asset=old_asset, author=self.student_one, title="Alt Selection", range1=43, range2=75
)
new_asset = AssetFactory(course=self.sample_course, author=self.student_one)
new_note = SherdNoteFactory(asset=new_asset, author=self.student_one, title="Selection", range1=43, range2=75)
text = (
'<p><a href="/asset/%s/annotations/%s/">Selection</a>'
'</p><p><a href="/asset/%s/annotations/%s/">Selection</a>'
'</p><p><a href="/asset/%s/annotations/%s/">Alt Selection</a>'
'</p><a href="/asset/%s/">Global</a></p>'
% (old_asset.id, old_note.id, old_asset.id, old_note.id, old_asset.id, alt_note.id, old_asset.id)
)
new_text = new_note.update_references_in_string(text, old_note)
citations = SherdNote.objects.references_in_string(new_text, old_note.author)
self.assertEquals(len(citations), 4)
self.assertEquals(citations[0].id, new_note.id)
self.assertEquals(citations[0].asset.id, new_note.asset.id)
self.assertEquals(citations[1].id, new_note.id)
self.assertEquals(citations[1].asset.id, new_note.asset.id)
self.assertEquals(citations[2].id, alt_note.id)
self.assertEquals(citations[2].asset.id, old_asset.id)
gann = old_asset.global_annotation(self.student_one, auto_create=False)
self.assertEquals(citations[3].id, gann.id)
self.assertEquals(citations[3].asset.id, old_asset.id)
开发者ID:ccnmtl,项目名称:mediathread,代码行数:34,代码来源:test_models.py
示例3: test_asset_detail
def test_asset_detail(self):
self.assertTrue(
self.client.login(username=self.instructor_one.username,
password='test'))
asset1 = AssetFactory.create(course=self.sample_course,
author=self.instructor_one,
primary_source='image')
response = self.client.get('/asset/%s/' % asset1.id, {},
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
the_json = json.loads(response.content)
self.assertTrue("space_owner" not in the_json)
self.assertEquals(len(the_json["panels"]), 1)
panel = the_json["panels"][0]
self.assertIsNone(panel["current_annotation"])
self.assertEquals(panel["current_asset"], str(asset1.id))
self.assertEquals(panel["panel_state"], "open")
self.assertEquals(panel["panel_state_label"], "Annotate Media")
self.assertTrue(panel["show_collection"])
self.assertEquals(panel["template"], "asset_workspace")
self.assertTrue(panel["update_history"])
self.assertEquals(len(panel["owners"]), 6)
context = panel["context"]
self.assertEquals(context["type"], "asset")
开发者ID:c0cky,项目名称:mediathread,代码行数:28,代码来源:test_views.py
示例4: setUp
def setUp(self):
self.setup_sample_course()
self.assignment = ProjectFactory.create(
course=self.sample_course,
author=self.instructor_one,
policy=PUBLISH_WHOLE_CLASS[0],
project_type="selection-assignment",
)
self.asset = AssetFactory.create(course=self.sample_course, primary_source="image")
self.assets = Asset.objects.filter(id=self.asset.id)
AssignmentItemFactory.create(project=self.assignment, asset=self.asset)
self.response_one = ProjectFactory.create(
course=self.sample_course, author=self.student_one, policy="PrivateEditorsAreOwners", parent=self.assignment
)
self.note_one = SherdNoteFactory(
asset=self.asset, author=self.student_one, body="student one selection note", range1=0, range2=1
)
ProjectNoteFactory(project=self.response_one, annotation=self.note_one)
self.response_two = ProjectFactory.create(
course=self.sample_course, author=self.student_two, policy="PrivateEditorsAreOwners", parent=self.assignment
)
self.note_two = SherdNoteFactory(
asset=self.asset, author=self.student_one, body="student one selection note", range1=0, range2=1
)
ProjectNoteFactory(project=self.response_two, annotation=self.note_two)
self.mixin = RestrictedMaterialsMixin()
self.mixin.request = RequestFactory().get("/")
self.mixin.request.course = self.sample_course
开发者ID:ccnmtl,项目名称:mediathread,代码行数:34,代码来源:test_mixins.py
示例5: test_embed_view
def test_embed_view(self):
asset = AssetFactory.create(course=self.sample_course,
primary_source='image',
author=self.instructor_one)
note = SherdNoteFactory(asset=asset, author=self.instructor_one,
title='Selection')
nonce = '%smthc' % datetime.datetime.now().isoformat()
digest = hmac.new(
'secret',
'%s:%s:%s' % (self.sample_course.id, note.id, nonce),
hashlib.sha1).hexdigest()
view = AssetEmbedView()
view.request = RequestFactory().get(
'/', {'nonce': nonce, 'hmac': digest},
HTTP_REFERER='http://testserver/a/b/c/')
view.request.course = self.sample_course
view.request.user = self.instructor_one
with self.assertRaises(Http404):
view.get_context_data(course_id=self.sample_course.id,
annot_id=note.id)
secrets = {'http://testserver/': 'secret'}
with self.settings(SERVER_ADMIN_SECRETKEYS=secrets):
ctx = view.get_context_data(course_id=self.sample_course.id,
annot_id=note.id)
self.assertTrue('item' in ctx)
self.assertEquals(ctx['item_id'], asset.id)
self.assertEquals(ctx['selection_id'], note.id)
self.assertEquals(ctx['presentation'], 'gallery')
self.assertEquals(ctx['title'], 'Selection')
开发者ID:c0cky,项目名称:mediathread,代码行数:34,代码来源:test_views.py
示例6: test_get_selection
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)
开发者ID:c0cky,项目名称:mediathread,代码行数:30,代码来源:test_views.py
示例7: setUp
def setUp(self):
self.setup_sample_course()
self.setup_alternate_course()
# instructor that sees both Sample Course & Alternate Course
self.instructor_three = UserFactory(username='instructor_three')
self.add_as_faculty(self.sample_course, self.instructor_three)
self.add_as_faculty(self.alt_course, self.instructor_three)
self.sample_course = Course.objects.get(title='Sample Course')
self.alt_course = Course.objects.get(title="Alternate Course")
self.asset1 = AssetFactory.create(course=self.sample_course,
author=self.instructor_one,
primary_source='image')
self.student_note = SherdNoteFactory(
asset=self.asset1, author=self.student_one,
tags=',student_one_selection',
body='student one selection note', range1=0, range2=1)
self.student_ga = SherdNoteFactory(
asset=self.asset1, author=self.student_one,
tags=',image, student_one_global,',
body='student one global note',
title=None, range1=None, range2=None)
self.instructor_note = SherdNoteFactory(
asset=self.asset1, author=self.instructor_one,
tags=',image, instructor_one_selection,',
body='instructor one selection note', range1=1, range2=2)
self.instructor_ga = SherdNoteFactory(
asset=self.asset1, author=self.instructor_one,
tags=',image, instructor_one_global,',
body='instructor one global note',
title=None, range1=None, range2=None)
self.asset2 = AssetFactory.create(course=self.sample_course,
author=self.instructor_one,
primary_source='video')
self.asset2_instructor_note = SherdNoteFactory(
asset=self.asset2, author=self.instructor_one,
tags=',video, instructor_one_selection,',
body='instructor one selection note', range1=0, range2=1)
self.asset2_instructor_ga = SherdNoteFactory(
asset=self.asset2, author=self.instructor_one,
tags=',video, instructor_one_global,',
body='instructor one global note',
title=None, range1=None, range2=None)
开发者ID:ccnmtl,项目名称:mediathread,代码行数:47,代码来源:test_api.py
示例8: test_upload_references
def test_upload_references(self):
asset1 = AssetFactory.create(
course=self.sample_course,
metadata_blob='{"wardenclyffe-id": ["29956"], "license": [""]}')
AssetFactory.create(
course=self.sample_course,
metadata_blob='{"wardenclyffe-id": ["29956"], "license": [""]}')
asset3 = AssetFactory.create(
course=self.sample_course,
metadata_blob='{"wardenclyffe-id": ["29957"], "license": [""]}')
asset4 = AssetFactory.create(
course=self.sample_course,
metadata_blob='{}')
self.assertEqual(asset1.upload_references(), 2)
self.assertEqual(asset3.upload_references(), 1)
self.assertEqual(asset4.upload_references(), 0)
开发者ID:ccnmtl,项目名称:mediathread,代码行数:17,代码来源:test_models.py
示例9: test_asset_workspace_course_lookup
def test_asset_workspace_course_lookup(self):
self.assertIsNone(asset_workspace_courselookup())
asset1 = AssetFactory.create(course=self.sample_course,
primary_source='image')
self.assertEquals(asset_workspace_courselookup(asset_id=asset1.id),
asset1.course)
开发者ID:c0cky,项目名称:mediathread,代码行数:8,代码来源:test_views.py
示例10: test_get_dimensions_video
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)
开发者ID:c0cky,项目名称:mediathread,代码行数:10,代码来源:test_views.py
示例11: test_annotation_create_global
def test_annotation_create_global(self):
asset = AssetFactory(course=self.sample_course, primary_source='image')
request = RequestFactory().post('/', {},
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
request.user = self.student_one
request.course = self.sample_course
response = annotation_create_global(request, asset.id)
self.assertEquals(response.status_code, 200)
ga = asset.global_annotation(self.student_one, auto_create=False)
self.assertIsNotNone(ga)
the_json = loads(response.content)
self.assertEquals(the_json['asset']['id'], asset.id)
self.assertEquals(the_json['annotation']['id'], ga.id)
# invalid asset
with self.assertRaises(Http404):
annotation_create_global(request, 1234)
开发者ID:c0cky,项目名称:mediathread,代码行数:19,代码来源:test_views.py
示例12: setUp
def setUp(self):
self.setup_sample_course()
self.setup_alternate_course()
# Sample Course Image Asset
self.asset1 = AssetFactory.create(course=self.sample_course,
primary_source='image')
self.student_note = SherdNoteFactory(
asset=self.asset1, author=self.student_one,
tags=',student_one_selection',
body='student one selection note', range1=0, range2=1)
self.student_ga = SherdNoteFactory(
asset=self.asset1, author=self.student_one,
tags=',student_one_item',
body='student one item note',
title=None, range1=None, range2=None)
self.instructor_note = SherdNoteFactory(
asset=self.asset1, author=self.instructor_one,
tags=',image, instructor_one_selection,',
body='instructor one selection note', range1=0, range2=1)
self.instructor_ga = SherdNoteFactory(
asset=self.asset1, author=self.instructor_one,
tags=',image, instructor_one_item,',
body='instructor one item note',
title=None, range1=None, range2=None)
# Sample Course Projects
self.project_private = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='PrivateEditorsAreOwners')
self.project_instructor_shared = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='InstructorShared')
self.project_class_shared = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='CourseProtected')
self.assignment = ProjectFactory.create(
course=self.sample_course, author=self.instructor_one,
policy='CourseProtected', project_type='assignment')
self.add_citation(self.assignment, self.student_note)
self.add_citation(self.assignment, self.instructor_note)
self.add_citation(self.assignment, self.student_ga)
self.add_citation(self.assignment, self.instructor_ga)
self.selection_assignment = ProjectFactory.create(
course=self.sample_course, author=self.instructor_one,
policy='CourseProtected', project_type='selection-assignment')
self.draft_assignment = ProjectFactory.create(
course=self.sample_course, author=self.instructor_one,
policy='PrivateEditorsAreOwners', project_type='assignment')
开发者ID:c0cky,项目名称:mediathread,代码行数:55,代码来源:test_models.py
示例13: setUp
def setUp(self):
self.setup_sample_course()
self.project = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='CourseProtected')
self.collaboration = self.project.get_collaboration()
self.asset = AssetFactory.create(course=self.sample_course,
primary_source='image')
self.asset2 = AssetFactory.create(course=self.sample_course,
primary_source='image')
self.note = SherdNoteFactory(
asset=self.asset, author=self.student_one,
tags=',student_one_selection',
body='student one selection note', range1=0, range2=1)
self.note2 = SherdNoteFactory(
asset=self.asset2, author=self.student_one, title='note2')
开发者ID:ccnmtl,项目名称:mediathread,代码行数:20,代码来源:test_models.py
示例14: setUp
def setUp(self):
# sandbox course
self.sandbox_course = CourseFactory(title="Mediathread Guest Sandbox")
self.sandbox_instructor = UserFactory(username='sandbox_instructor')
self.sandbox_student = UserFactory(username='sandbox_student')
self.add_as_student(self.sandbox_course, self.sandbox_student)
self.add_as_faculty(self.sandbox_course, self.sandbox_instructor)
self.sandbox_asset_instructor = AssetFactory.create(
course=self.sandbox_course, author=self.sandbox_instructor,
primary_source='image')
self.sandbox_note_instructor = SherdNoteFactory(
asset=self.sandbox_asset_instructor,
author=self.sandbox_instructor)
self.sandbox_note_student = SherdNoteFactory(
asset=self.sandbox_asset_instructor, author=self.sandbox_student)
self.sandbox_asset_student = AssetFactory.create(
course=self.sandbox_course, author=self.sandbox_student,
primary_source='image')
self.sandbox_project_instructor = ProjectFactory.create(
course=self.sandbox_course, author=self.sandbox_instructor,
policy='PrivateEditorsAreOwners')
self.sandbox_project_student = ProjectFactory.create(
course=self.sandbox_course, author=self.sandbox_student,
policy='PrivateEditorsAreOwners')
# sample course
self.setup_sample_course()
self.add_as_faculty(self.sample_course, self.sandbox_instructor)
sample_asset = AssetFactory.create(
course=self.sample_course, author=self.sandbox_instructor,
primary_source='image')
SherdNote.objects.global_annotation(
sample_asset, self.sandbox_instructor, auto_create=True)
ProjectFactory.create(
course=self.sample_course, author=self.sandbox_instructor,
policy='PrivateEditorsAreOwners')
开发者ID:avorio,项目名称:mediathread,代码行数:41,代码来源:test_commands.py
示例15: test_save
def test_save(self):
asset1 = AssetFactory.create(course=self.sample_course,
primary_source='image')
asset2 = AssetFactory.create(course=self.sample_course,
primary_source='youtube')
url = reverse('project-save', args=[self.project.id])
# author
self.client.login(username=self.instructor_one.username,
password='test')
data = {
'title': 'Updated',
'body': 'Body Text',
'item': asset1.id
}
response = self.client.post(url, data)
self.assertEquals(response.status_code, 405)
response = self.client.post(url, data,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEquals(response.status_code, 200)
# verify
project = Project.objects.get(id=self.project.id)
self.assertEquals(project.title, 'Updated')
self.assertEquals(project.body, 'Body Text')
self.assertEquals(project.assignmentitem_set.count(), 1)
self.assertEquals(project.assignmentitem_set.first().asset, asset1)
# swap out the asset
data = {
'title': 'Updated',
'body': 'Body Text',
'item': asset2.id
}
response = self.client.post(url, data,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEquals(response.status_code, 200)
self.assertEquals(project.assignmentitem_set.count(), 1)
self.assertEquals(project.assignmentitem_set.first().asset, asset2)
开发者ID:c0cky,项目名称:mediathread,代码行数:41,代码来源:test_views.py
示例16: test_project
def test_project(self):
asset = AssetFactory.create(course=self.sample_course,
primary_source='image')
note = SherdNoteFactory(
asset=asset, author=self.student_one,
tags=',student_one_selection',
body='student one selection note', range1=0, range2=1)
asset2 = AssetFactory.create(course=self.sample_course,
primary_source='image')
to_be_deleted = SherdNoteFactory(
asset=asset2, author=self.student_one, title='to be deleted')
project = ProjectFactory.create(
course=self.sample_course, author=self.student_one,
policy='CourseProtected')
self.add_citation(project, note)
self.add_citation(project, to_be_deleted)
asset2.delete()
collaboration = project.get_collaboration()
DiscussionIndex.update_class_references(project.body,
None, None,
collaboration,
project.author)
indicies = DiscussionIndex.objects.all()
self.assertEquals(indicies.count(), 1)
index = indicies.first()
self.assertIsNone(index.participant)
self.assertIsNone(index.comment)
self.assertEquals(index.collaboration, collaboration)
self.assertEquals(index.asset, asset)
self.assertEquals(index.get_type_label(), 'project')
self.assertEquals(index.content_object, asset)
self.assertEquals(index.clump_parent(), project)
self.assertIsNone(index.get_parent_url())
self.assertEquals(index.body, '')
开发者ID:c0cky,项目名称:mediathread,代码行数:40,代码来源:test_models.py
示例17: test_annotation_save_no_annotation_exists
def test_annotation_save_no_annotation_exists(self):
asset1 = AssetFactory.create(course=self.sample_course,
primary_source='image',
title="Item Title")
self.assert_(self.client.login(username=self.instructor_one.username,
password="test"))
url = "/asset/save/%s/annotations/%s/" % (asset1.id, 42)
post_data = {'annotation-range1': -4.5}
response = self.client.post(url, post_data,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEquals(response.status_code, 403)
开发者ID:c0cky,项目名称:mediathread,代码行数:13,代码来源:test_views.py
示例18: test_most_recent
def test_most_recent(self):
self.assertTrue(
self.client.login(username=self.instructor_one.username,
password='test'))
asset1 = AssetFactory.create(course=self.sample_course,
primary_source='image',
author=self.instructor_one)
response = self.client.get('/asset/most_recent/', {}, follow=True)
self.assertEquals(response.status_code, 200)
url = 'http://testserver/asset/%s/' % asset1.id
self.assertEquals(response.redirect_chain, [(url, 302)])
开发者ID:c0cky,项目名称:mediathread,代码行数:14,代码来源:test_views.py
示例19: test_get_iframe_url
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)
开发者ID:c0cky,项目名称:mediathread,代码行数:16,代码来源:test_views.py
注:本文中的mediathread.factories.AssetFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论