Skip to content

Commit fc54960

Browse files
committed
local_id
1 parent e7c98f5 commit fc54960

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

backend/src/log_structure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def wrapper(*args, **kwargs):
3535
"actual_path": actual_path,
3636
"resource_path": resource_path,
3737
}
38+
39+
if event.get("body"):
40+
imms = json.loads(event["body"])
41+
local_id = imms["identifier"][0]["value"] + "^" + imms["identifier"][0]["system"]
42+
log_data["local_id"] = local_id
43+
3844
operation_outcome = dict()
3945
firehose_log = dict()
4046
start = time.time()

backend/tests/test_log_structure_wrapper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def test_successful_execution(self, mock_logger, mock_firehose_logger):
2525
'X-Request-ID': 'test_request'
2626
},
2727
'path': '/test',
28-
'requestContext': {'resourcePath': '/test'}
28+
'requestContext': {'resourcePath': '/test'},
29+
'body': "{\"identifier\": [{\"system\": \"http://test\", \"value\": \"12345\"}]}"
2930
}
3031

3132
# Act
@@ -45,6 +46,7 @@ def test_successful_execution(self, mock_logger, mock_firehose_logger):
4546
self.assertEqual(logged_info['X-Request-ID'], 'test_request')
4647
self.assertEqual(logged_info['actual_path'], '/test')
4748
self.assertEqual(logged_info['resource_path'], '/test')
49+
self.assertEqual(logged_info['local_id'], '12345^http://test')
4850

4951
def test_exception_handling(self, mock_logger, mock_firehose_logger):
5052

@@ -57,7 +59,9 @@ def test_exception_handling(self, mock_logger, mock_firehose_logger):
5759
'X-Correlation-ID': 'failed_test_correlation',
5860
'X-Request-ID': 'failed_test_request'
5961
},
60-
'path': '/failed_test', 'requestContext': {'resourcePath': '/failed_test'}}
62+
'path': '/failed_test', 'requestContext': {'resourcePath': '/failed_test'},
63+
'body': "{\"identifier\": [{\"system\": \"http://test\", \"value\": \"12345\"}]}"}
64+
6165
context = {}
6266
decorated_function_raises(event, context)
6367

@@ -75,3 +79,4 @@ def test_exception_handling(self, mock_logger, mock_firehose_logger):
7579
self.assertEqual(logged_info['actual_path'], '/failed_test')
7680
self.assertEqual(logged_info['resource_path'], '/failed_test')
7781
self.assertEqual(logged_info['error'], str(ValueError("Test error")))
82+
self.assertEqual(logged_info['local_id'], '12345^http://test')

0 commit comments

Comments
 (0)