本文整理汇总了Python中osf_tests.factories.DraftRegistrationFactory.update_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python DraftRegistrationFactory.update_metadata方法的具体用法?Python DraftRegistrationFactory.update_metadata怎么用?Python DraftRegistrationFactory.update_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf_tests.factories.DraftRegistrationFactory
的用法示例。
在下文中一共展示了DraftRegistrationFactory.update_metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPreregFiles
# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import update_metadata [as 别名]
#.........这里部分代码省略.........
# Test Approved removes checkout
self.draft.approval.state = 'approved'
self.draft.approval.save()
file_q7 = self.d_of_qs['q7']
file_q7.checkout = self.admin_user
file_q7.save()
view = CheckoutCheckupView()
view = setup_user_view(view, request, user=self.admin_user)
view.delete(request, user=self.admin_user)
file_q7.refresh_from_db()
assert file_q7.checkout is None
# Test Rejected removes checkout
self.draft.approval.state = 'rejected'
self.draft.approval.save()
file_q7 = self.d_of_qs['q7']
file_q7.checkout = self.admin_user
file_q7.save()
view = CheckoutCheckupView()
view = setup_user_view(view, request, user=self.admin_user)
view.delete(request, user=self.admin_user)
file_q7.refresh_from_db()
assert file_q7.checkout is None
# Test Unapprove does not remove checkout
self.draft.approval.state = 'unapproved'
self.draft.approval.save()
file_q7 = self.d_of_qs['q7']
file_q7.checkout = self.admin_user
file_q7.save()
view = CheckoutCheckupView()
view = setup_user_view(view, request, user=self.admin_user)
view.delete(request, user=self.admin_user)
file_q7.refresh_from_db()
assert file_q7.checkout == self.admin_user
def test_get_meta_data_files(self):
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_get_file_questions(self):
questions = get_file_questions('prereg-prize.json')
nt.assert_equal(7, len(questions))
nt.assert_list_equal(
[
(u'q7', u'Data collection procedures'),
(u'q11', u'Manipulated variables'),
(u'q12', u'Measured variables'),
(u'q13', u'Indices'),
(u'q16', u'Study design'),
(u'q19', u'Statistical models'),
(u'q26', u'Upload an analysis script with clear comments')
],
questions
)
def test_file_id_missing(self):
data = self.draft.registration_metadata
data['q7']['value']['uploader']['extra'][0].pop('fileId')
self.draft.update_metadata(data)
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_file_id_missing_odd(self):
data = self.draft.registration_metadata
data['q26']['extra'][0].pop('fileId')
self.draft.update_metadata(data)
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_wrong_provider(self):
data = self.draft.registration_metadata
data['q7']['value']['uploader']['extra'][0]['data']['provider'] = 'box'
self.draft.update_metadata(data)
with nt.assert_raises(Http404):
for item in get_metadata_files(self.draft):
pass
def test_wrong_provider_odd(self):
data = self.draft.registration_metadata
data['q26']['extra'][0]['data']['provider'] = 'box'
self.draft.update_metadata(data)
with nt.assert_raises(Http404):
for item in get_metadata_files(self.draft):
pass
def test_delete_pre_submit_draft_does_not_change_checkouts(self):
file_q7 = self.d_of_qs['q7']
file_q7.checkout = self.user
file_q7.save()
utils.checkin_files(self.draft)
file_q7.refresh_from_db()
nt.assert_equal(file_q7.checkout, self.user)
示例2: TestPreregFiles
# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import update_metadata [as 别名]
#.........这里部分代码省略.........
]
}
continue
data[q] = {
'value': {
'uploader': {
'extra': [
{
'data': {
'provider': 'osfstorage',
'path': f.path,
},
'fileId': guid,
'nodeId': self.node._id,
}
]
}
}
}
self.draft = DraftRegistrationFactory(
initiator=self.user,
registration_schema=prereg_schema,
registration_metadata=data
)
self.prereg_user.save()
self.admin_user = UserFactory()
def test_checkout_files(self):
self.draft.submit_for_review(self.user, {}, save=True)
request = RequestFactory().get('/fake_path')
view = DraftDetailView()
view = setup_user_view(view, request, self.admin_user,
draft_pk=self.draft._id)
view.checkout_files(self.draft)
for q, f in self.d_of_qs.iteritems():
f.refresh_from_db()
nt.assert_equal(self.admin_user, f.checkout)
def test_checkin_files(self):
self.draft.submit_for_review(self.user, {}, save=True)
request = RequestFactory().get('/fake_path')
view = DraftDetailView()
view = setup_user_view(view, request, self.admin_user,
draft_pk=self.draft._id)
view.checkout_files(self.draft)
view2 = DraftFormView()
view2 = setup_view(view2, request, draft_pk=self.draft._id)
view2.checkin_files(self.draft)
for q, f in self.d_of_qs.iteritems():
nt.assert_equal(None, f.checkout)
def test_get_meta_data_files(self):
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_get_file_questions(self):
questions = get_file_questions('prereg-prize.json')
nt.assert_equal(7, len(questions))
nt.assert_list_equal(
[
(u'q7', u'Data collection procedures'),
(u'q11', u'Manipulated variables'),
(u'q12', u'Measured variables'),
(u'q13', u'Indices'),
(u'q16', u'Study design'),
(u'q19', u'Statistical models'),
(u'q26', u'Upload an analysis script with clear comments')
],
questions
)
def test_file_id_missing(self):
data = self.draft.registration_metadata
data['q7']['value']['uploader']['extra'][0].pop('fileId')
self.draft.update_metadata(data)
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_file_id_missing_odd(self):
data = self.draft.registration_metadata
data['q26']['extra'][0].pop('fileId')
self.draft.update_metadata(data)
for item in get_metadata_files(self.draft):
nt.assert_in(type(item), [OsfStorageFile, OsfStorageFileNode])
def test_wrong_provider(self):
data = self.draft.registration_metadata
data['q7']['value']['uploader']['extra'][0]['data']['provider'] = 'box'
self.draft.update_metadata(data)
with nt.assert_raises(Http404):
for item in get_metadata_files(self.draft):
pass
def test_wrong_provider_odd(self):
data = self.draft.registration_metadata
data['q26']['extra'][0]['data']['provider'] = 'box'
self.draft.update_metadata(data)
with nt.assert_raises(Http404):
for item in get_metadata_files(self.draft):
pass