Test/add lambda client unit tests#1028
Conversation
Greptile SummaryThis PR adds 13 unit tests for Confidence Score: 5/5Safe to merge; all remaining findings are P2 style/coverage suggestions with no blocking issues. Both findings are P2: one is a test-coverage gap (malformed REPORT format means duration parsing isn't exercised in the multi-invocation test) and the other is a minor assertion-placement style issue. Neither breaks the test suite or production behavior. tests/services/test_lambda_client.py — minor REPORT format and assertion-scope issues noted inline. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[test_get_function_configuration_success] --> B[get_function_configuration]
C[test_get_function_configuration_error] --> B
D[test_get_function_code_success] --> E[get_function_code]
F[test_get_function_code_no_extract] --> E
G[test_get_function_code_too_large] --> E
H[test_get_function_code_download_error] --> E
I[test_get_function_code_corrupt_zip] --> E
J[test_get_recent_invocations_success] --> K[get_recent_invocations]
L[test_get_recent_invocations_resource_not_found] --> K
M[test_get_recent_invocations_multiple] --> K
N[test_get_invocation_logs_by_request_id_success] --> O[get_invocation_logs_by_request_id]
P[test_invoke_function_success] --> Q[invoke_function]
R[test_list_functions_success] --> S[list_functions]
E -->|extract_files=True, size < 5MB| T{Download ZIP}
T -->|200 OK| U[Parse files: text / binary / truncated]
T -->|non-200| V[skip files key]
T -->|bad ZIP| W[extract_error key]
E -->|extract_files=False OR size >= 5MB| V
K --> X{Parse CloudWatch events}
X -->|START| Y[new invocation]
X -->|END| Z[set end_time]
X -->|REPORT| AA[parse duration + memory, flush invocation]
X -->|other| BB[append to current logs]
Reviews (1): Last reviewed commit: "fix: resolve ruff formatting issues" | Re-trigger Greptile |
|
@muddlebee PTAL! |
Fixes #887
Describe the changes you have made in this PR -
Added direct unit tests for the Lambda service client in
app/services/lambda_client.py. These tests ensure that function inspection, code extraction, and log retrieval logic are directly protected by unit tests rather than just through tool-level tests.Key coverage includes:
get_function_configuration.ZipFilein memory to verify extraction of text files.max_file_size.get_recent_invocationscorrectly groups START, END, and REPORT log events into discrete invocation objects.ResourceNotFoundExceptionfor missing log groups or functions.invoke_functionandlist_functions.Demo/Screenshot for feature changes and bug fixes -
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
The tests utilize
unittest.mockto stubboto3clients andrequests.getto avoid any real AWS or network calls. A memory-residentZipFilewas used to simulate deployment package extraction, allowing for precise testing of text, binary, and size-limited file handling. The log parsing logic was tested against realistic CloudWatch Log event sequences to ensure robust grouping of Lambda invocations.Checklist before requesting a review