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


Python base.capture_signals函数代码示例

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


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


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