Repository navigation
Closed
Labels
ecp-wp4: M4.1ELIXIR Compute Platform WP4 milestone/deliverable this issue contributes topriority: highHigh prioritytype: testingRelated to code testingworkload: daysLikely takes days to resolve
Description
Why?
The FOCA upgrade (#65) and the access control work (#62) change how requests are routed, validated and authorized. The current tests cannot catch regressions there:
- All tests call the controller functions or classes directly inside a bare
Flaskapp context with a hand-built FOCA config. No test goes through the app, so OpenAPI validation, status codes, authentication and the error handlers incloud_registry/exceptions.pyare never exercised.app.pyhas no tests at all (Test: Write test cases forapp.py#32), and[tool.coverage.run]omits it from coverage. - The same setup (build a
Config, swap in amongomockcollection) is repeated in almost every test intests/ga4gh/registry/instead of using fixtures. test_register_metadata_duplicate_keys_repeated(tests/ga4gh/registry/test_service.py:149-174) does not test what it says. It modifies a copycustom_config(settinglengthtwice) but builds the app from the unmodifiedCUSTOM_CONFIG, and themongomockcollection has no unique index onid. It passes only because the firstregister_metadata()call adds an_idto the shareddatadict, so the second call fails on a duplicate_id. This is how the ID-retry bug in Bug: service ID retry never generates a new ID #72 went unnoticed.
How?
- Add
tests/conftest.pywith fixtures for the base config, amongomockdatabase (with the unique indexes fromconfig.yaml), and an app built withFoca(...).create_app()using connexion's test client. - Mock token validation in the fixture (the same pattern as
tests/test_access_control.pyin feat!: add owner-based access control #66), so authenticated and unauthenticated requests can both be tested without a real identity provider. - Add app-level tests for every endpoint: success paths,
404for unknown IDs, an empty database, PUT create vs. replace, request validation errors (400), missing or invalid token (401), and the error response format. - Test
app.pystartup (config loading, service-info registration) and remove it from the coverageomitlist. - Rewrite the duplicate-ID test so it actually exhausts the ID space (one-character IDs with a unique index), together with the fix in Bug: service ID retry never generates a new ID #72.
- Convert the existing unit tests to the shared fixtures.
Acceptance criteria
- Each endpoint has at least one test that goes through the app and asserts the status code and response body.
-
app.pyis covered and no longer omitted from coverage. - The duplicate-ID test fails on the current code and passes with Bug: service ID retry never generates a new ID #72.
- The same tests pass on the feat!: upgrade to FOCA 0.14.0 #65 branch (FOCA 0.14).
Dependencies: #69. Do together with #72.
Part of the ELIXIR Compute Platform WP4 sprint (M&Ds due end of December 2026).
Metadata
Metadata
Assignees
Labels
ecp-wp4: M4.1ELIXIR Compute Platform WP4 milestone/deliverable this issue contributes topriority: highHigh prioritytype: testingRelated to code testingworkload: daysLikely takes days to resolve
Activity
test: add app test harness, fix ID retry (elixir-cloud-aai#90)