当前位置: 首页>>代码示例>>Python>>正文


Python CommentFactory.build方法代码示例

本文整理汇总了Python中tests.factories.CommentFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python CommentFactory.build方法的具体用法?Python CommentFactory.build怎么用?Python CommentFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.factories.CommentFactory的用法示例。


在下文中一共展示了CommentFactory.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def _set_up_public_project_comment_reports(self):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user)
     self.public_project.add_contributor(contributor=self.contributor, save=True)
     self.public_comment = CommentFactory.build(node=self.public_project, target=self.public_project, user=self.contributor)
     self.public_comment.reports = {self.user._id: {'category': 'spam', 'text': 'This is spam'}}
     self.public_comment.save()
     self.public_url = '/{}comments/{}/reports/{}/'.format(API_BASE, self.public_comment._id, self.user._id)
开发者ID:mchelen,项目名称:osf.io,代码行数:9,代码来源:test_comment_report_detail.py

示例2: test_public_node_logged_in_non_contributor_reporter_can_view_report_detail

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_public_node_logged_in_non_contributor_reporter_can_view_report_detail(self):
     project = ProjectFactory(is_public=True, comment_level='public')
     comment = CommentFactory.build(node=project, user=project.creator)
     comment.reports = {self.non_contributor._id: {'category': 'spam', 'text': 'This is spam'}}
     comment.save()
     url = '/{}comments/{}/reports/{}/'.format(API_BASE, comment._id, self.non_contributor._id)
     res = self.app.get(url, auth=self.non_contributor.auth)
     assert_equal(res.status_code, 200)
开发者ID:mchelen,项目名称:osf.io,代码行数:10,代码来源:test_comment_report_detail.py

示例3: test_public_node_reporting_contributor_can_delete_detail

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_public_node_reporting_contributor_can_delete_detail(self):
     self._set_up_public_project_file_comment_reports()
     comment = CommentFactory.build(node=self.public_project, target=self.public_file, user=self.contributor)
     comment.reports = {self.user._id: {'category': 'spam', 'text': 'This is spam'}}
     comment.save()
     url = '/{}comments/{}/reports/{}/'.format(API_BASE, comment._id, self.user._id)
     res = self.app.delete_json_api(url, auth=self.user.auth)
     assert_equal(res.status_code, 204)
开发者ID:mchelen,项目名称:osf.io,代码行数:10,代码来源:test_comment_report_detail.py

示例4: _set_up_private_project_file_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def _set_up_private_project_file_comment_reports(self):
     self.private_project = ProjectFactory.build(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, user=self.contributor)
     self.comment.reports = self.comment.reports or {}
     self.comment.reports[self.user._id] = {'category': 'spam', 'text': 'This is spam'}
     self.comment.save()
     self.private_url = '/{}comments/{}/reports/'.format(API_BASE, self.comment._id)
开发者ID:mchelen,项目名称:osf.io,代码行数:11,代码来源:test_comment_report_list.py

示例5: _set_up_private_project_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def _set_up_private_project_comment_reports(self):
     self.private_project = ProjectFactory.build(is_public=False, creator=self.user)
     self.private_project.add_contributor(contributor=self.contributor, save=True)
     self.comment = CommentFactory.build(node=self.private_project, target=self.private_project, user=self.contributor)
     self.comment.reports = {self.user._id: {
         'category': 'spam',
         'text': 'This is spam',
         'date': datetime.utcnow(),
         'retracted': False,
     }}
     self.comment.save()
     self.private_url = '/{}comments/{}/reports/{}/'.format(API_BASE, self.comment._id, self.user._id)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:14,代码来源:test_comment_report_detail.py

示例6: test_private_node_reporting_contributor_can_delete_report_detail

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_private_node_reporting_contributor_can_delete_report_detail(self):
     self._set_up_private_project_comment_reports()
     comment = CommentFactory.build(node=self.private_project, target=self.private_project, user=self.contributor)
     comment.reports = {self.user._id: {
         'category': 'spam',
         'text': 'This is spam',
         'date': datetime.utcnow(),
         'retracted': False,
     }}
     comment.save()
     url = '/{}comments/{}/reports/{}/'.format(API_BASE, comment._id, self.user._id)
     res = self.app.delete_json_api(url, auth=self.user.auth)
     assert_equal(res.status_code, 204)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:15,代码来源:test_comment_report_detail.py

示例7: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from 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': datetime.utcnow(),
         'retracted': False,
     }
     self.public_comment.save()
     self.public_url = '/{}comments/{}/reports/'.format(API_BASE, self.public_comment._id)
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:15,代码来源:test_comment_report_list.py

示例8: test_public_node_non_contributor_reporter_can_view_report

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_public_node_non_contributor_reporter_can_view_report(self):
     project = ProjectFactory(is_public=True, comment_level='public')
     comment = CommentFactory.build(node=project, user=project.creator)
     comment.reports = comment.reports or {}
     comment.reports[self.non_contributor._id] = {'category': 'spam', 'text': 'This is spam.'}
     comment.save()
     url = '/{}comments/{}/reports/'.format(API_BASE, comment._id)
     res = self.app.get(url, auth=self.non_contributor.auth)
     assert_equal(res.status_code, 200)
     report_json = res.json['data']
     report_ids = [report['id'] for report in report_json]
     assert_equal(len(report_json), 1)
     assert_in(self.non_contributor._id, report_ids)
开发者ID:Alpani,项目名称:osf.io,代码行数:15,代码来源:test_comment_report_list.py

示例9: _set_up_private_project_file_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def _set_up_private_project_file_comment_reports(self):
     self.private_project = ProjectFactory.build(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, user=self.contributor)
     self.comment.reports = self.comment.reports or {}
     self.comment.reports[self.user._id] = {
         "category": "spam",
         "text": "This is spam",
         "date": datetime.utcnow(),
         "retracted": False,
     }
     self.comment.save()
     self.private_url = "/{}comments/{}/reports/".format(API_BASE, self.comment._id)
开发者ID:KAsante95,项目名称:osf.io,代码行数:16,代码来源:test_comment_report_list.py

示例10: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def _set_up_public_project_comment_reports(self, comment_level="public"):
     self.public_project = ProjectFactory.build(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, target=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": datetime.utcnow(),
         "retracted": False,
     }
     self.public_comment.save()
     self.public_url = "/{}comments/{}/reports/".format(API_BASE, self.public_comment._id)
开发者ID:KAsante95,项目名称:osf.io,代码行数:17,代码来源:test_comment_report_list.py

示例11: test_private_node_logged_out_user_cannot_undelete_comment

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_private_node_logged_out_user_cannot_undelete_comment(self):
     self._set_up_private_project_with_comment()
     comment = CommentFactory.build(node=self.private_project, target=self.private_project, user=self.user)
     comment.is_deleted = True
     comment.save()
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     payload = {
         'data': {
             'id': comment._id,
             'type': 'comments',
             'attributes': {
                 'deleted': False
             }
         }
     }
     res = self.app.patch_json_api(url, payload, expect_errors=True)
     assert_equal(res.status_code, 401)
开发者ID:mchelen,项目名称:osf.io,代码行数:19,代码来源:test_comment_detail.py

示例12: test_private_node_non_contributor_cannot_undelete_file_comment

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_private_node_non_contributor_cannot_undelete_file_comment(self):
     self._set_up_private_project_with_file_comment()
     comment = CommentFactory.build(node=self.private_project, target=self.file, user=self.user)
     comment.is_deleted = True
     comment.save()
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     payload = {
         'data': {
             'id': comment._id,
             'type': 'comments',
             'attributes': {
                 'deleted': False
             }
         }
     }
     res = self.app.patch_json_api(url, payload, auth=self.non_contributor.auth, expect_errors=True)
     assert_equal(res.status_code, 403)
     assert_equal(res.json['errors'][0]['detail'], 'You do not have permission to perform this action.')
开发者ID:mchelen,项目名称:osf.io,代码行数:20,代码来源:test_comment_detail.py

示例13: test_private_node_logged_out_user_cannot_undelete_file_comment

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_private_node_logged_out_user_cannot_undelete_file_comment(self):
     self._set_up_private_project_with_file_comment()
     comment = CommentFactory.build(node=self.private_project, target=self.file.get_guid(), user=self.user)
     comment.is_deleted = True
     comment.save()
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     payload = {
         'data': {
             'id': comment._id,
             'type': 'comments',
             'attributes': {
                 'deleted': False
             }
         }
     }
     res = self.app.patch_json_api(url, payload, expect_errors=True)
     assert_equal(res.status_code, 401)
     assert_equal(res.json['errors'][0]['detail'], 'Authentication credentials were not provided.')
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:20,代码来源:test_comment_detail.py

示例14: test_private_node_only_logged_in_contributor_commenter_can_undelete_file_comment

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_private_node_only_logged_in_contributor_commenter_can_undelete_file_comment(self):
     self._set_up_private_project_with_file_comment()
     comment = CommentFactory.build(node=self.private_project, target=self.file, user=self.user)
     comment.is_deleted = True
     comment.save()
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     payload = {
         'data': {
             'id': comment._id,
             'type': 'comments',
             'attributes': {
                 'deleted': False
             }
         }
     }
     res = self.app.patch_json_api(url, payload, auth=self.user.auth)
     assert_equal(res.status_code, 200)
     assert_false(res.json['data']['attributes']['deleted'])
     assert_equal(res.json['data']['attributes']['content'], comment.content)
开发者ID:mchelen,项目名称:osf.io,代码行数:21,代码来源:test_comment_detail.py

示例15: test_public_node_logged_in_non_contributor_reporter_can_update_report_detail

# 需要导入模块: from tests.factories import CommentFactory [as 别名]
# 或者: from tests.factories.CommentFactory import build [as 别名]
 def test_public_node_logged_in_non_contributor_reporter_can_update_report_detail(self):
     project = ProjectFactory(is_public=True, comment_level='public')
     comment = CommentFactory.build(node=project, user=project.creator)
     comment.reports = {self.non_contributor._id: {'category': 'spam', 'text': 'This is spam'}}
     comment.save()
     url = '/{}comments/{}/reports/{}/'.format(API_BASE, comment._id, self.non_contributor._id)
     payload = {
         'data': {
             'id': self.non_contributor._id,
             'type': 'comment_reports',
             'attributes': {
                 'category': 'spam',
                 'message': 'Spam is delicious.'
             }
         }
     }
     res = self.app.put_json_api(url, payload, auth=self.non_contributor.auth)
     assert_equal(res.status_code, 200)
     assert_equal(res.json['data']['attributes']['message'], payload['data']['attributes']['message'])
开发者ID:mchelen,项目名称:osf.io,代码行数:21,代码来源:test_comment_report_detail.py


注:本文中的tests.factories.CommentFactory.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。