本文整理汇总了Python中qiita_db.study.Study.share方法的典型用法代码示例。如果您正苦于以下问题:Python Study.share方法的具体用法?Python Study.share怎么用?Python Study.share使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiita_db.study.Study
的用法示例。
在下文中一共展示了Study.share方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_edit_blank_doi
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import share [as 别名]
def test_post_edit_blank_doi(self):
study_count_before = get_count('qiita.study')
study = Study(1)
study_info = study.info
post_data = {
'new_people_names': [],
'new_people_emails': [],
'new_people_affiliations': [],
'new_people_addresses': [],
'new_people_phones': [],
'study_title': 'New title - test post edit',
'study_alias': study_info['study_alias'],
'publications_doi': '',
'study_abstract': study_info['study_abstract'],
'study_description': study_info['study_description'],
'principal_investigator': study_info['principal_investigator'].id,
'lab_person': study_info['lab_person'].id}
response = self.post('/study/edit/1', post_data)
self.assertEqual(response.code, 200)
# Check that the study was updated
self.assertTrue(check_count('qiita.study', study_count_before))
self.assertEqual(study.title, 'New title - test post edit')
self.assertEqual(study.publications, [])
# check for failure
old_title = post_data['study_title']
post_data['study_title'] = 'My new title!'
shared = User('[email protected]')
study.unshare(shared)
BaseHandler.get_current_user = Mock(return_value=shared)
response = self.post('/study/edit/1', post_data)
self.assertEqual(response.code, 403)
# Check that the study wasn't updated
self.assertEqual(study.title, old_title)
# returning sharing
study.share(shared)
示例2: TestStudy
# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import share [as 别名]
#.........这里部分代码省略.........
'study_alias': 'alias',
'study_abstract': 'abstract'}
user = User('[email protected]')
Study.create(user, 'test_study_1', efo=[1], info=info)
obs = Study.get_info(info_cols=exp_keys)
exp = [[True, ['123456', '7891011'], False,
'Identification of the Microbiomes for Cannabis Soils',
'None'],
[False, None, False, 'test_study_1', 'None']]
self.assertEqual(obs, exp)
# test portal restriction working
qiita_config.portal = 'EMP'
with self.assertRaises(QiitaDBError):
Study.get_info([1])
def test_has_access_public(self):
self._change_processed_data_status('public')
qiita_config.portal = 'QIITA'
self.assertTrue(self.study.has_access(User("[email protected]")))
qiita_config.portal = 'EMP'
with self.assertRaises(QiitaDBError):
Study(1).has_access(User("[email protected]"))
def test_has_access_no_public(self):
self._change_processed_data_status('public')
self.assertFalse(self.study.has_access(User("[email protected]"), True))
def test_owner(self):
self.assertEqual(self.study.owner, "[email protected]")
def test_share(self):
# Clear all sharing associations
self._change_processed_data_status('sandbox')
self.conn_handler.execute("delete from qiita.study_users")
self.assertEqual(self.study.shared_with, [])
# Try to share with the owner, which should not work
self.study.share(User("[email protected]"))
self.assertEqual(self.study.shared_with, [])
# Then share the study with [email protected]
self.study.share(User("[email protected]"))
self.assertEqual(self.study.shared_with, ["[email protected]"])
def test_unshare(self):
self._change_processed_data_status('sandbox')
self.study.unshare(User("[email protected]"))
self.assertEqual(self.study.shared_with, [])
def test_has_access_shared(self):
self._change_processed_data_status('sandbox')
self.assertTrue(self.study.has_access(User("[email protected]")))
def test_has_access_private(self):
self._change_processed_data_status('sandbox')
self.assertTrue(self.study.has_access(User("[email protected]")))
def test_has_access_admin(self):
self._change_processed_data_status('sandbox')
self.assertTrue(self.study.has_access(User("[email protected]")))
def test_has_access_no_access(self):
self._change_processed_data_status('sandbox')