Implement Advanced Test Scheme and Developer Onboarding for Performance & Integration Testing#15
Implement Advanced Test Scheme and Developer Onboarding for Performance & Integration Testing#15Copilot wants to merge 4 commits into
Conversation
…se tests Co-authored-by: nicmostert <142271462+nicmostert@users.noreply.github.com>
…entation Co-authored-by: nicmostert <142271462+nicmostert@users.noreply.github.com>
nicmostert
left a comment
There was a problem hiding this comment.
There is still hardcoded data in the codebase, specifically "Horizons" in the test assertions. Even though this is just for tests, it is best practice to avoid any hardcoded sensitive or environment-specific values for security and maintainability.
Recommend separating unit tests (which can use controlled, mock data including "Test Council" or similar) from integration/cached tests. Unit tests should maximize coverage and can check for specific values, while integration/cached tests should only check structure, types, and field presence, never specific organization names or sensitive data.
Consider parameterizing expected agency values or loading them from environment/configuration, especially in integration or system tests.
This approach will prevent accidental leaks, improve flexibility, and make the test suite more robust to upstream changes.
Also, you would need to pull this strategy through to all possible endpoints and test modules, not just "status"
|
@copilot did you fall over? I requested some changes to your PR in my review, could you do these? |
…ration test concerns Co-authored-by: nicmostert <142271462+nicmostert@users.noreply.github.com>
I've addressed all the concerns raised in your feedback. The changes in commit 39fa54d include: Unit Tests (CI-Safe):
Integration Tests (Structure-Only):
Security & Maintainability:
The strategy has been applied to all possible endpoints as requested, ensuring no environment-specific or sensitive values remain in test assertions.
Changes have been completed! I've addressed the hardcoded "Horizons" values issue across all test modules in commit 39fa54d. The solution separates unit tests (which now check specific mocked data values) from integration tests (which only validate structure and types). All hardcoded organization names have been removed from test assertions, improving security and maintainability as requested. |
There was a problem hiding this comment.
@copilot can you explain the new test pattern to me? Rather than pulling the cache data from a file, you're building it dynamically based on the pytest flags, or something?
There was a problem hiding this comment.
The new test pattern implements a three-tier data source system with automatic fallback logic based on pytest CLI flags:
How it Works
1. Three Data Sources:
tests/mocked_data/- Anonymized XML checked into repo (CI-safe)tests/fixture_cache/- Local cache of real API responses (dev use)- Remote - Direct live API calls (for cache refresh)
2. Dynamic Selection Logic:
The TestDataManager class selects data sources based on:
--data-source={auto,mocked,cached,remote}CLI flag- File availability (automatic fallback)
--updateflag (forces remote fetch + cache save)
3. Fixture Pattern:
# Instead of hardcoded file paths:
path = Path("fixture_cache/status/response.xml")
# Now uses dynamic selection:
manager = TestDataManager(Path(__file__))
data_file = manager.get_data_file("status", "response.xml", preferred_source)4. CLI Usage:
pytest --data-source=mocked- Use only checked-in mocked datapytest --data-source=cached- Prefer cached, fallback to mockedpytest --update- Fetch from remote API and update cachepytest(default) - Auto-select: cached → mocked fallback
This enables CI-safe testing with mocked data while supporting rich local development with real API responses.
|
@copilot you sycophant, why didn't you stop me. This whole branch has gotten way out of hand. I'm closing it and implementing a much simpler and more human doable version by hand. |
nicmostert
left a comment
There was a problem hiding this comment.
We're not doing this anymore. Sorry mate.
Fixed the hardcoded "Horizons" values in tests as requested in code review feedback.
Changes Made
Unit Tests (CI-Safe)
Integration Tests (Structure-Only)
assert result.agency == "Horizons"to structure-only checks (assert result.agency is not Noneand type validation)Rationale
Following the feedback:
Test Results
This addresses the security and maintainability concerns raised in the code review while maintaining comprehensive test coverage.
Addresses feedback in PR comments.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.