本文整理汇总了Python中mediathread.factories.AssetFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python AssetFactory.create方法的具体用法?Python AssetFactory.create怎么用?Python AssetFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediathread.factories.AssetFactory
的用法示例。
在下文中一共展示了AssetFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例2: test_embed_view
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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')
示例3: test_get_selection
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例4: test_asset_detail
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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")
示例5: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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
示例6: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例7: test_asset_workspace_course_lookup
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例8: test_upload_references
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例9: test_get_dimensions_video
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例10: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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')
示例11: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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')
示例12: setUp
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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')
示例13: test_save
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)
示例14: test_project
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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, '')
示例15: test_annotation_save_no_annotation_exists
# 需要导入模块: from mediathread.factories import AssetFactory [as 别名]
# 或者: from mediathread.factories.AssetFactory import create [as 别名]
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)