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()
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)
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)
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)
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)
def test_not_whitelisted_no_predicate(self, command, ctx): wrapped_command = (channel_whitelisted())(command) self.expect_fail(wrapped_command, ctx)
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()
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)
def test_whitelisted_no_predicate(self): self.whitelist_channel() wrapped_command = (channel_whitelisted())(self.command) self.expect_success(wrapped_command)
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)