Skip to content

Commit

Permalink
Merge pull request #43 from Workable/bug/38_application_factory_crash
Browse files Browse the repository at this point in the history
Bug/38 application factory crash
  • Loading branch information
sque authored Oct 31, 2019
2 parents 772903f + 45c28d3 commit 7df476c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flask_log_request_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import parser


__version__ = '0.9.3'
__version__ = '0.9.4'


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion flask_log_request_id/request_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _persist_request_id():
setattr(g, g_object_attr, self._request_id_generator())

# Register after request
if self.app.config['LOG_REQUEST_ID_LOG_ALL_REQUESTS']:
if app.config['LOG_REQUEST_ID_LOG_ALL_REQUESTS']:
app.after_request(self._log_http_event)

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions tests/request_id_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def setUp(self):
self.app.route('/')(lambda: 'hello world')
self.app.testing = True

def test_lazy_initialization(self):
# Bug #38: https://github.com/Workable/flask-log-request-id/issues/38
request_id = RequestID()
request_id.init_app(self.app)
with self.app.test_request_context(headers={'X-Amzn-Trace-Id': 'Self=1-67891234-def;Root=1-67891233-abc'}):
self.app.preprocess_request()
self.assertEqual('1-67891234-def', current_request_id())

def test_default_request_id_parser_with_amazon(self):
RequestID(self.app)
with self.app.test_request_context(headers={'X-Amzn-Trace-Id': 'Self=1-67891234-def;Root=1-67891233-abc'}):
Expand Down

0 comments on commit 7df476c

Please sign in to comment.