fix: Resolve all test failures and improve error handling #25
fix: Resolve all test failures and improve error handling #25jona42-ui wants to merge 2 commits intoeclipse-thingweb:mainfrom
Conversation
…reusable=True to HTTP mock callbacks (fixes 21 tests) - Fixed IDNotFound exception to use proper error handler instead of abort() Fixes eclipse-thingweb#24 Signed-off-by: jona42-ui <jonathanthembo123@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to resolve current CI test failures and make error handling consistent with the app’s AppException JSON error responses (Fixes #24).
Changes:
- Made
pytest_httpxcallbacks reusable in SPARQL mock fixtures to avoid callback exhaustion across multiple requests. - Replaced
abort(404)with raisingIDNotFoundso Flask’sAppExceptionhandler returnsapplication/problem+json. - Updated the test TDD description fixture to include
response.contentTypefields and reformatted JSON.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tdd/tests/data/tdd-description.json | Reformats test fixture and adds missing response.contentType entries. |
| tdd/tests/conftest.py | Updates httpx_mock.add_callback usage to be reusable across requests. |
| tdd/lib/init.py | Adds package marker so tdd.lib works with importlib.resources. |
| tdd/errors.py | Expands IDNotFound to provide a clearer title and localized messages. |
| tdd/common.py | Switches 404 handling from abort() to raising IDNotFound. |
| .gitignore | Ignores local venv and generated JS artifacts under tdd/lib. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from tdd.errors import IDNotFound | ||
|
|
||
| raise IDNotFound() |
There was a problem hiding this comment.
abort is no longer used after switching to raising IDNotFound, but tdd/common.py still imports it (from flask import Response, abort). This will trigger flake8 F401 (unused import). Remove abort from the import list (or reintroduce its usage if intended).
tdd/lib/__init__.py
Outdated
| @@ -0,0 +1 @@ | |||
| # JavaScript library module | |||
There was a problem hiding this comment.
This file is only used to make tdd.lib a Python package for importlib.resources; the current comment # JavaScript library module is potentially misleading given it’s a Python package. Consider replacing it with a short module docstring clarifying it exists to package/access built JS assets.
| # JavaScript library module | |
| """Package providing access to built JavaScript assets via importlib.resources.""" |
Fixes #24