Skip to content

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

Open
sliedig wants to merge 9 commits into
developfrom
cross-runtime-test-consolidation
Open

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

Conversation

@sliedig

@sliedig sliedig commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

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
sliedig added 3 commits March 26, 2026 00:43
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.
- Remove pytest.ini files from all three services (approvals, contracts, web)
- Migrate pytest configuration to pyproject.toml [tool.pytest.ini_options]
- Update pythonpath from "." to "src" for correct import resolution
- Add coverage omit patterns to exclude schema modules in approvals and web services
- Consolidate configuration management into single pyproject.toml per service for easier maintenance
# Conflicts:
#	unicorn_approvals/pyproject.toml
#	unicorn_approvals/uv.lock
#	unicorn_contracts/pyproject.toml
#	unicorn_contracts/uv.lock
#	unicorn_web/pyproject.toml
#	unicorn_web/uv.lock
@sliedig

sliedig commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Synced this branch with develop (merge commit 19ef1c1) to pick up the recent Python dependency bumps.

Conflicts resolved: all 3 pyproject.toml files had adjacent-line conflicts between this branch's pytest-cov addition and develop's newer dependency floors (pytest, ruff, tomli, etc.). Kept pytest-cov and took develop's newer floors. All 3 uv.lock files were regenerated fresh via uv lock from the resolved manifests rather than hand-merging the lockfile conflict markers.

Verified after merge: all 3 services pass their full test suite (6/10/15 tests) with the 80% coverage gate intact (82–92% per service).

@sliedig sliedig removed the request for review from a team July 3, 2026 06:46
This was referenced Jul 3, 2026
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