• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python base.capture_signals函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.base.capture_signals函数的典型用法代码示例。如果您正苦于以下问题:Python capture_signals函数的具体用法?Python capture_signals怎么用?Python capture_signals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_preprint_contributor_signal_not_sent_one_contributor

 def test_preprint_contributor_signal_not_sent_one_contributor(self):
     with capture_signals() as mock_signals:
         private_project_payload = build_preprint_create_payload(self.private_project._id, self.subject._id,
                                                                self.file_one_private_project._id)
         res = self.app.post_json_api(self.url, private_project_payload, auth=self.user.auth)
         assert_equal(res.status_code, 201)
         assert_not_equal(mock_signals.signals_sent(), set([project_signals.contributor_added]))
开发者ID:alexschiller,项目名称:osf.io,代码行数:7,代码来源:test_preprint_list.py


示例2: test_preprint_contributor_signal_not_sent_on_creation

    def test_preprint_contributor_signal_not_sent_on_creation(self):
        with capture_signals() as mock_signals:
            public_project_payload = build_preprint_create_payload(self.public_project._id, self.provider._id,
                                                                   self.file_one_public_project._id)
            res = self.app.post_json_api(self.url, public_project_payload, auth=self.user.auth)

            assert_equal(res.status_code, 201)
            assert_not_in(project_signals.contributor_added, mock_signals.signals_sent())
开发者ID:adlius,项目名称:osf.io,代码行数:8,代码来源:test_preprint_list.py


示例3: test_edit_sends_mention_added_signal_if_mentions

 def test_edit_sends_mention_added_signal_if_mentions(self):
     with capture_signals() as mock_signals:
         self.comment.edit(
             auth=self.auth,
             content="This is a comment with a bad mention [@Mentioned User](http://localhost:5000/"
             + self.comment.user._id
             + "/).",
             save=True,
         )
     assert_equal(mock_signals.signals_sent(), set([mention_added]))
开发者ID:ycchen1989,项目名称:osf.io,代码行数:10,代码来源:test_comments.py


示例4: test_create_sends_comment_added_signal

 def test_create_sends_comment_added_signal(self, node, user, auth):
     with capture_signals() as mock_signals:
         Comment.create(
             auth=auth,
             user=user,
             node=node,
             target=node.guids.all()[0],
             content='This is a comment.'
         )
     assert mock_signals.signals_sent() == ({comment_added})
开发者ID:erinspace,项目名称:osf.io,代码行数:10,代码来源:test_comment.py


示例5: test_create_sends_mention_added_signal_if_mentions

 def test_create_sends_mention_added_signal_if_mentions(self, node, user, auth):
     with capture_signals() as mock_signals:
         Comment.create(
             auth=auth,
             user=user,
             node=node,
             target=node.guids.all()[0],
             content='This is a comment with a bad mention [@Unconfirmed User](http://localhost:5000/' + user._id + '/).'
         )
     assert mock_signals.signals_sent() == ({comment_added, mention_added})
开发者ID:erinspace,项目名称:osf.io,代码行数:10,代码来源:test_comment.py


示例6: test_edit_sends_mention_added_signal_if_mentions

 def test_edit_sends_mention_added_signal_if_mentions(self):
     comment = CommentFactory()
     auth = Auth(comment.user)
     with capture_signals() as mock_signals:
         comment.edit(
             auth=auth,
             content='This is a comment with a bad mention [@Mentioned User](http://localhost:5000/' + comment.user._id + '/).',
             save=True
         )
     assert mock_signals.signals_sent() == ({mention_added})
开发者ID:erinspace,项目名称:osf.io,代码行数:10,代码来源:test_comment.py


示例7: test_edit_does_not_send_mention_added_signal_if_nonuser_mentioned

 def test_edit_does_not_send_mention_added_signal_if_nonuser_mentioned(self):
     with assert_raises(ValidationValueError) as error:
         with capture_signals() as mock_signals:
             self.comment.edit(
                 auth=self.auth,
                 content="This is a comment with a bad mention [@Not a User](http://localhost:5000/qwert/).",
                 save=True,
             )
     assert_equal(mock_signals.signals_sent(), set([]))
     assert_equal(error.exception.message, "User does not exist or is not active.")
开发者ID:ycchen1989,项目名称:osf.io,代码行数:10,代码来源:test_comments.py


示例8: test_edit_does_not_send_mention_added_signal_if_already_mentioned

 def test_edit_does_not_send_mention_added_signal_if_already_mentioned(self):
     comment = CommentFactory()
     auth = Auth(comment.user)
     with capture_signals() as mock_signals:
         comment.ever_mentioned.add(comment.user)
         comment.edit(
             auth=auth,
             content='This is a comment with a bad mention [@Already Mentioned User](http://localhost:5000/' + comment.user._id + '/).',
             save=True
         )
     assert mock_signals.signals_sent() == set([])
开发者ID:erinspace,项目名称:osf.io,代码行数:11,代码来源:test_comment.py


示例9: test_create_sends_comment_added_signal

 def test_create_sends_comment_added_signal(self):
     with capture_signals() as mock_signals:
         comment = Comment.create(
             auth=self.auth,
             user=self.comment.user,
             node=self.comment.node,
             target=self.comment.target,
             is_public=True,
             content='This is a comment.'
         )
     assert_equal(mock_signals.signals_sent(), set([comment_added]))
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:11,代码来源:test_comments.py


示例10: test_edit_does_not_send_mention_added_signal_if_already_mentioned

 def test_edit_does_not_send_mention_added_signal_if_already_mentioned(self):
     with capture_signals() as mock_signals:
         self.comment.ever_mentioned = [self.comment.user._id]
         self.comment.edit(
             auth=self.auth,
             content="This is a comment with a bad mention [@Already Mentioned User](http://localhost:5000/"
             + self.comment.user._id
             + "/).",
             save=True,
         )
     assert_equal(mock_signals.signals_sent(), set([]))
开发者ID:ycchen1989,项目名称:osf.io,代码行数:11,代码来源:test_comments.py


示例11: test_edit_does_not_send_mention_added_signal_if_nonuser_mentioned

 def test_edit_does_not_send_mention_added_signal_if_nonuser_mentioned(self):
     comment = CommentFactory()
     auth = Auth(comment.user)
     with pytest.raises(ValidationError) as error:
         with capture_signals() as mock_signals:
             comment.edit(
                 auth=auth,
                 content='This is a comment with a bad mention [@Not a User](http://localhost:5000/qwert/).',
                 save=True
             )
     assert mock_signals.signals_sent() == set([])
     assert error.value.message == 'User does not exist or is not active.'
开发者ID:erinspace,项目名称:osf.io,代码行数:12,代码来源:test_comment.py


示例12: test_create_does_not_send_mention_added_signal_if_nonuser_mentioned

 def test_create_does_not_send_mention_added_signal_if_nonuser_mentioned(self, node, user, auth):
     with pytest.raises(ValidationError) as error:
         with capture_signals() as mock_signals:
             Comment.create(
                 auth=auth,
                 user=user,
                 node=node,
                 target=node.guids.all()[0],
                 content='This is a comment with a bad mention [@Not a User](http://localhost:5000/qwert/).'
             )
     assert mock_signals.signals_sent() == set([])
     assert error.value.message == 'User does not exist or is not active.'
开发者ID:erinspace,项目名称:osf.io,代码行数:12,代码来源:test_comment.py


示例13: test_create_does_not_send_mention_added_signal_if_noncontributor_mentioned

 def test_create_does_not_send_mention_added_signal_if_noncontributor_mentioned(self, node, user, auth):
     with pytest.raises(ValidationError) as error:
         with capture_signals() as mock_signals:
             user = UserFactory()
             Comment.create(
                 auth=auth,
                 user=user,
                 node=node,
                 target=node.guids.all()[0],
                 content='This is a comment with a bad mention [@Non-contributor User](http://localhost:5000/' + user._id + '/).'
             )
     assert mock_signals.signals_sent() == set([])
     assert error.value.message == 'Mentioned user is not a contributor.'
开发者ID:erinspace,项目名称:osf.io,代码行数:13,代码来源:test_comment.py


示例14: test_preprint_contributor_signal_sent_on_creation

    def test_preprint_contributor_signal_sent_on_creation(self):
        # Signal sent but bails out early without sending email
        with capture_signals() as mock_signals:
            payload = build_preprint_create_payload(
                provider_id=self.provider._id)
            res = self.app.post_json_api(
                self.url, payload, auth=self.user.auth)

            assert_equal(res.status_code, 201)
            assert_true(len(mock_signals.signals_sent()) == 1)
            assert_in(
                project_signals.contributor_added,
                mock_signals.signals_sent())
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:13,代码来源:test_preprint_list.py


示例15: test_create_sends_mention_added_signal_if_mentions

 def test_create_sends_mention_added_signal_if_mentions(self):
     with capture_signals() as mock_signals:
         comment = Comment.create(
             auth=self.auth,
             user=self.comment.user,
             node=self.comment.node,
             target=self.comment.target,
             is_public=True,
             content="This is a comment with a bad mention [@Unconfirmed User](http://localhost:5000/"
             + self.comment.user._id
             + "/).",
         )
     assert_equal(mock_signals.signals_sent(), set([comment_added, mention_added]))
开发者ID:ycchen1989,项目名称:osf.io,代码行数:13,代码来源:test_comments.py


示例16: test_removed_contrib_files_checked_in

 def test_removed_contrib_files_checked_in(self, app, node, file):
     write_contrib = AuthUserFactory()
     node.add_contributor(write_contrib, permissions=['read', 'write'])
     node.save()
     assert node.can_edit(user=write_contrib)
     file.checkout = write_contrib
     file.save()
     assert file.is_checked_out
     with capture_signals() as mock_signals:
         node.remove_contributor(write_contrib, auth=Auth(write_contrib))
     assert mock_signals.signals_sent() == set([contributor_removed])
     file.reload()
     assert not file.is_checked_out
开发者ID:icereval,项目名称:osf.io,代码行数:13,代码来源:test_file_detail.py


示例17: test_edit_does_not_send_mention_added_signal_if_noncontributor_mentioned

 def test_edit_does_not_send_mention_added_signal_if_noncontributor_mentioned(self):
     comment = CommentFactory()
     auth = Auth(comment.user)
     with pytest.raises(ValidationError) as error:
         with capture_signals() as mock_signals:
             user = UserFactory()
             comment.edit(
                 auth=auth,
                 content='This is a comment with a bad mention [@Non-contributor User](http://localhost:5000/' + user._id + '/).',
                 save=True
             )
     assert mock_signals.signals_sent() == set([])
     assert error.value.message == 'Mentioned user is not a contributor.'
开发者ID:erinspace,项目名称:osf.io,代码行数:13,代码来源:test_comment.py


示例18: test_removed_contrib_files_checked_in

 def test_removed_contrib_files_checked_in(self):
     user = AuthUserFactory()
     self.node.add_contributor(user, permissions=['read', 'write'])
     self.node.save()
     assert_true(self.node.can_edit(user=user))
     self.file.checkout = user
     self.file.save()
     assert_true(self.file.is_checked_out)
     with capture_signals() as mock_signals:
         self.node.remove_contributor(user, auth=Auth(user))
     assert_equal(mock_signals.signals_sent(), set([contributor_removed]))
     self.file.reload()
     assert_false(self.file.is_checked_out)
开发者ID:ccfair,项目名称:osf.io,代码行数:13,代码来源:test_file_detail.py


示例19: test_create_does_not_send_mention_added_signal_if_nonuser_mentioned

 def test_create_does_not_send_mention_added_signal_if_nonuser_mentioned(self):
     with assert_raises(ValidationValueError) as error:
         with capture_signals() as mock_signals:
             comment = Comment.create(
                 auth=self.auth,
                 user=self.comment.user,
                 node=self.comment.node,
                 target=self.comment.target,
                 is_public=True,
                 content="This is a comment with a bad mention [@Not a User](http://localhost:5000/qwert/).",
             )
     assert_equal(mock_signals.signals_sent(), set([]))
     assert_equal(error.exception.message, "User does not exist or is not active.")
开发者ID:ycchen1989,项目名称:osf.io,代码行数:13,代码来源:test_comments.py


示例20: test_edit_does_not_send_mention_added_signal_if_noncontributor_mentioned

 def test_edit_does_not_send_mention_added_signal_if_noncontributor_mentioned(self):
     with assert_raises(ValidationValueError) as error:
         with capture_signals() as mock_signals:
             user = UserFactory()
             self.comment.edit(
                 auth=self.auth,
                 content="This is a comment with a bad mention [@Non-contributor User](http://localhost:5000/"
                 + user._id
                 + "/).",
                 save=True,
             )
     assert_equal(mock_signals.signals_sent(), set([]))
     assert_equal(error.exception.message, "Mentioned user is not a contributor.")
开发者ID:ycchen1989,项目名称:osf.io,代码行数:13,代码来源:test_comments.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.get_default_metaschema函数代码示例发布时间:2022-05-27
下一篇:
Python base.assert_is_redirect函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap