コード例 #1
0
 def test_middleware_writes_logs(self, write_log):
     start_response_mock = mock.MagicMock()
     app = requestlog.RequestLog(self.application)
     app(self.environ, start_response_mock)
     write_log.assert_called_once_with(self.environ,
                                       '/resource_providers?name=myrp',
                                       '200 OK', '0')
コード例 #2
0
 def test_middleware_sends_message(self, mocked_log):
     start_response_mock = mock.MagicMock()
     app = requestlog.RequestLog(self.application)
     app(self.environ, start_response_mock)
     mocked_log.debug.assert_called_once_with(
         'Starting request: 127.0.0.1 "GET /resource_providers?name=myrp"')
     mocked_log.info.assert_called_once_with(
         '127.0.0.1 "GET /resource_providers?name=myrp" '
         'status: 200 len: 0')
コード例 #3
0
 def test_middleware_sends_message(self, mocked_log):
     start_response_mock = mock.MagicMock()
     app = requestlog.RequestLog(self.application)
     app(self.environ, start_response_mock)
     mocked_log.debug.assert_called_once_with(
         'Starting request: %s "%s %s"', '127.0.0.1', 'GET',
         '/resource_providers?name=myrp')
     mocked_log.info.assert_called_once_with(
         '%(REMOTE_ADDR)s "%(REQUEST_METHOD)s %(REQUEST_URI)s" '
         'status: %(status)s len: %(bytes)s microversion: %(microversion)s',
         {'microversion': '2.1',
          'status': '200',
          'REQUEST_URI': '/resource_providers?name=myrp',
          'REQUEST_METHOD': 'GET',
          'REMOTE_ADDR': '127.0.0.1',
          'bytes': '0'})