Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fix_develop_branch_version
Browse files Browse the repository at this point in the history
  • Loading branch information
sque authored Oct 31, 2019
2 parents d22d190 + 7df476c commit 0b165fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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 0b165fb

Please sign in to comment.