本文整理汇总了Python中osf_tests.factories.CommentFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python CommentFactory.build方法的具体用法?Python CommentFactory.build怎么用?Python CommentFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf_tests.factories.CommentFactory
的用法示例。
在下文中一共展示了CommentFactory.build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_up_public_project_comment_reports
# 需要导入模块: from osf_tests.factories import CommentFactory [as 别名]
# 或者: from osf_tests.factories.CommentFactory import build [as 别名]
def _set_up_public_project_comment_reports(self, comment_level='public'):
self.public_project = ProjectFactory.create(is_public=True, creator=self.user, comment_level=comment_level)
self.public_project.add_contributor(contributor=self.contributor, save=True)
self.public_comment = CommentFactory.build(node=self.public_project, user=self.contributor)
self.public_comment.reports = self.public_comment.reports or {}
self.public_comment.reports[self.user._id] = {
'category': 'spam',
'text': 'This is spam',
'date': timezone.now(),
'retracted': False,
}
self.public_comment.save()
self.public_url = '/{}comments/{}/reports/'.format(API_BASE, self.public_comment._id)
示例2: _set_up_private_project_comment_reports
# 需要导入模块: from osf_tests.factories import CommentFactory [as 别名]
# 或者: from osf_tests.factories.CommentFactory import build [as 别名]
def _set_up_private_project_comment_reports(self):
self.private_project = ProjectFactory.create(is_public=False, creator=self.user)
self.private_project.add_contributor(contributor=self.contributor, save=True)
self.file = test_utils.create_test_file(self.private_project, self.user)
self.comment = CommentFactory.build(node=self.private_project, target=self.file.get_guid(), user=self.contributor)
self.comment.reports = self.comment.reports or {}
self.comment.reports[self.user._id] = {
'category': 'spam',
'text': 'This is spam',
'date': timezone.now(),
'retracted': False,
}
self.comment.save()
self.private_url = '/{}comments/{}/reports/'.format(API_BASE, self.comment._id)
示例3: test_private_node_delete_report_detail_auth_misc
# 需要导入模块: from osf_tests.factories import CommentFactory [as 别名]
# 或者: from osf_tests.factories.CommentFactory import build [as 别名]
def test_private_node_delete_report_detail_auth_misc(
self, app, user, contributor, non_contrib,
private_project, private_url, comment
):
# test_private_node_reported_contributor_cannot_delete_report_detail
res = app.delete_json_api(
private_url, auth=contributor.auth,
expect_errors=True
)
assert res.status_code == 403
# test_private_node_logged_in_non_contrib_cannot_delete_report_detail
res = app.delete_json_api(
private_url, auth=non_contrib.auth,
expect_errors=True
)
assert res.status_code == 403
# test_private_node_logged_out_contributor_cannot_delete_detail
res = app.delete_json_api(private_url, expect_errors=True)
assert res.status_code == 401
# test_private_node_reporting_contributor_can_delete_report_detail
comment_new = CommentFactory.build(
node=private_project,
user=contributor,
target=comment.target
)
comment_new.reports = {user._id: {
'category': 'spam',
'text': 'This is spam',
'date': timezone.now(),
'retracted': False,
}}
comment_new.save()
url = '/{}comments/{}/reports/{}/'.format(
API_BASE, comment_new._id, user._id)
res = app.delete_json_api(url, auth=user.auth)
assert res.status_code == 204