示例#1
0
 def test_whitelisted_predicate_no_exception(self, command, ctx, mocker,
                                             session):
     self.whitelist_channel(session, ctx)
     exc_pred = mocker.Mock(return_value=False)
     wrapped_command = (channel_whitelisted(exc_pred))(command)
     self.expect_success(wrapped_command, ctx)
     exc_pred.assert_not_called()
示例#2
0
 def test_whitelisted_no_predicate(self, command, ctx, session):
     self.whitelist_channel(session, ctx)
     wrapped_command = (channel_whitelisted())(command)
     self.expect_success(wrapped_command, ctx)
示例#3
0
 def test_whitelisted_uncallable_predicate(self, command, ctx, mocker,
                                           session):
     self.whitelist_channel(session, ctx)
     exc_pred = mocker.NonCallableMock()
     wrapped_command = (channel_whitelisted(exc_pred))(command)
     self.expect_success(wrapped_command, ctx)
示例#4
0
 def test_not_whitelisted_uncallable_predicate(self, command, ctx, mocker):
     exc_pred = mocker.NonCallableMock()
     wrapped_command = (channel_whitelisted(exc_pred))(command)
     self.expect_fail(wrapped_command, ctx)
示例#5
0
 def test_not_whitelisted_predicate_exception(self, command, ctx, mocker):
     exc_pred = mocker.Mock(return_value=True)
     wrapped_command = (channel_whitelisted(exc_pred))(command)
     self.expect_success(wrapped_command, ctx)
     exc_pred.assert_called_once_with(ctx)
示例#6
0
 def test_not_whitelisted_no_predicate(self, command, ctx):
     wrapped_command = (channel_whitelisted())(command)
     self.expect_fail(wrapped_command, ctx)
示例#7
0
 def test_whitelisted_predicate_exception(self):
     self.whitelist_channel()
     exc_pred = mock.Mock(return_value=True)
     obj = (channel_whitelisted(exc_pred))(self.command)
     self.expect_success(obj)
     exc_pred.assert_not_called()
示例#8
0
 def test_whitelisted_uncallable_predicate(self):
     self.whitelist_channel()
     exc_pred = mock.NonCallableMock()
     wrapped_command = (channel_whitelisted(exc_pred))(self.command)
     self.expect_success(wrapped_command)
示例#9
0
 def test_whitelisted_no_predicate(self):
     self.whitelist_channel()
     wrapped_command = (channel_whitelisted())(self.command)
     self.expect_success(wrapped_command)
示例#10
0
 def test_not_whitelisted_predicate_no_exception(self):
     exc_pred = mock.Mock(return_value=False)
     wrapped_command = (channel_whitelisted(exc_pred))(self.command)
     self.expect_fail(wrapped_command)
     exc_pred.assert_called_once_with(self.ctx)