test: standardize unit tests across all services (31 tests)#180
Open
test: standardize unit tests across all services (31 tests)#180
Conversation
…verError - Remove unused datetime import and current_date variable calculation - Replace InternalServerError with EnvironmentError for environment variable validation - Simplify error handling for SERVICE_NAMESPACE and CONTRACT_STATUS_TABLE checks - InternalServerError is not appropriate for environment configuration issues that occur at module initialization
…d remove unused metric - Add validation for evaluation_result to ensure only "APPROVED" or "DECLINED" values are processed - Return early with skip message when unknown evaluation result is encountered - Log warning when evaluation result is invalid for debugging purposes - Remove unused PropertiesAdded metric that was not being utilized - Improve robustness by preventing invalid data from being written to DynamoDB
…trics - Import timezone from datetime module for UTC timestamp generation - Import MetricUnit from aws_lambda_powertools.metrics for proper metric typing - Replace strftime formatting with isoformat() for ISO 8601 compliant timestamps in create_contract and update_contract functions - Add metric tracking for successful contract creation events - Rename UpdateExpression attribute from modified_date to contract_last_modified_on for consistency - Ensures timestamps are timezone-aware and use UTC for consistency across distributed systems
- Add actions: read permission for workflow execution access - Add contents: read permission for repository content access - Scope down GitHub Token permissions following security best practices
Add coverage tooling (pytest-cov, 80% minimum), extend test cases for all 7 Lambda functions, and remove extra tests to ensure parity with .NET, Java, and TypeScript runtimes.
Align event fixture values (address number 111, seller "John Doe") to match other runtimes. Remove unused create_contract_invalid_1.json. Update helper seed data and inline test data to use consistent values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: N/A
Summary
Changes
Standardize unit tests across all 3 Python services to achieve exact parity with the .NET, Java, and TypeScript runtimes (31 identical test cases across 7 Lambda functions).
pytest-covto dev dependencies with--cov-fail-under=80enforcement in all 3pyproject.tomlfilestest_handle_status_changed_approved(previously a no-op due to moto limitation) usingunittest.mock.patchto mock the SFN client directlytest_missing_ddb_env_var,test_missing_sm_env_var,test_wrong_dynamodb_table) to align test cases across runtimesUser experience
Workshop participants running
pytestwill see the same 31 test cases as in the other 3 runtimes, with 80% coverage enforced at build time.Checklist
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.