Skip to content

test: standardize unit tests across all services (31 tests)#180

Open
sliedig wants to merge 7 commits intodevelopfrom
cross-runtime-test-consolidation
Open

test: standardize unit tests across all services (31 tests)#180
sliedig wants to merge 7 commits intodevelopfrom
cross-runtime-test-consolidation

Conversation

@sliedig
Copy link
Contributor

@sliedig sliedig commented Mar 23, 2026

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).

  • Add pytest-cov to dev dependencies with --cov-fail-under=80 enforcement in all 3 pyproject.toml files
  • Extend test cases for ContractStatusChangedEventHandler, PropertiesApprovalSyncFunction, WaitForContractApprovalFunction, RequestApprovalFunction, PublicationEvaluationEventHandler, and PropertySearchFunction
  • Implement test_handle_status_changed_approved (previously a no-op due to moto limitation) using unittest.mock.patch to mock the SFN client directly
  • Remove 3 extra environment/infrastructure tests from ContractEventHandler (test_missing_ddb_env_var, test_missing_sm_env_var, test_wrong_dynamodb_table) to align test cases across runtimes

User experience

Workshop participants running pytest will 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.

sliedig added 6 commits March 16, 2026 09:31
…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.
@sliedig sliedig requested a review from a team as a code owner March 23, 2026 09:08
@github-actions github-actions bot requested a review from igorlg March 23, 2026 09:08
@sliedig sliedig changed the base branch from main to develop March 24, 2026 04:40
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants