class LoggingAndMonitoringFixture(unittest.TestCase): def setUp(self): self._subscriber_registry = Registry() self._commandProcessor = CommandProcessor(registry=self._subscriber_registry) def test_logging_a_handler(self): """s Given that I have a handler decorated for logging When I call that handler Then I should receive logs indicating the call and return of the handler * N.b. This is an example of using decorators to extend the Brightside pipeline """ handler = MyCommandHandler() request = MyCommand() self._subscriber_registry.register(MyCommand, lambda: handler) logger = logging.getLogger("tests.handlers_testdoubles") with patch.object(logger, 'log') as mock_log: self._commandProcessor.send(request) mock_log.assert_has_calls([call(logging.DEBUG, "Entering handle " + str(request)), call(logging.DEBUG, "Exiting handle " + str(request))])
def setUp(self): self._subscriber_registry = Registry() self._commandProcessor = CommandProcessor(registry=self._subscriber_registry)