Repository navigation
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
soxofaan
left a comment
There was a problem hiding this comment.
use more parameterization in the tests to reduce boilerplate and clarify the tested behavior
| assert api100.validation(pg).json["errors"][0]["code"] == "ProcessUnsupported" | ||
|
|
||
|
|
||
| def test_validate_user_defined_process_invalid_graph(api100, udp_registry): |
There was a problem hiding this comment.
what is exactly invalid about this graph in this test?
|
@copilot address the review comments |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
|
||
| return decorated | ||
|
|
||
| def optional_bearer_auth(self, f: Callable): |
There was a problem hiding this comment.
add basic test coverage for this new functionality
see tests/users/test_auth.py
| - `load_stac` with STAC metadata where "bands" dimension is erroneously missing: "bands" dimension will still be forced in dry run if "bands" argument is given to `load_stac` ([Open-EO/openeo-geopyspark-driver#1907](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1907)) | ||
| - Improve compatibility (address failing unit tests) with Python 3.12, 3.13 and 3.14 ([#541](https://github.com/Open-EO/openeo-python-driver/issues/541)) | ||
| - `export_workspace`: support not merging `derived_from` links into a STAC Collection. ([Open-EO/openeo-geopyspark-driver#1922](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1922)) | ||
| - Resolve the authenticated user's processes during preflight validation ([#286](https://github.com/Open-EO/openeo-python-driver/issues/286)). |
There was a problem hiding this comment.
| - Resolve the authenticated user's processes during preflight validation ([#286](https://github.com/Open-EO/openeo-python-driver/issues/286)). | |
| - Support user info in endpoints with optional auth. And improve support for user defined processes during (preflight) validation ([#286](https://github.com/Open-EO/openeo-python-driver/issues/286)). |
|
|
||
|
|
||
| @pytest.fixture | ||
| def udp_call_definition(): |
There was a problem hiding this comment.
using a fixture is overkill and obfuscates/hides the coupling that is going in here
for the "UDP call" as you call it, only the "process_graph" entry is relevant anyway
There was a problem hiding this comment.
I now see that you are doing it this way combined with changing the "call" body in-place, which makes this even worse for readability
|
|
||
|
|
||
| @pytest.fixture | ||
| def udp_definition(): |
There was a problem hiding this comment.
I'm not a fan of using fixtures when a simple constant would work too.
I'd prefer grouping the tests in test class and having this "UDP definition" as class constant
| pytest.param(None, 200, None, id="anonymous"), | ||
| pytest.param(TEST_USER, 200, None, id="authenticated"), | ||
| pytest.param("invalid-token", 403, "TokenInvalid", id="invalid-token"), | ||
| pytest.param("Mark", 403, "PermissionsInsufficient", id="access-denied"), |
There was a problem hiding this comment.
Strange: why would this fail for "Mark" but not TEST_USER?
| assert response.json == {"errors": expected_errors} | ||
|
|
||
|
|
||
| def test_validate_user_defined_process_with_unsupported_inner_process(api100, udp_definition, udp_call_definition): |
There was a problem hiding this comment.
I think these two tests test_validate_user_defined_process and test_validate_user_defined_process_with_unsupported_inner_process can be merged with appropriate parameterization
| [ | ||
| pytest.param("user", TEST_USER, True, id="user-namespace"), | ||
| pytest.param(None, TEST_USER, True, id="null-namespace"), | ||
| pytest.param("_undefined", TEST_USER, True, id="implicit-namespace"), |
There was a problem hiding this comment.
I'm not sure this "_undefined" case is very relevant, it's functionally the same as the None case
| if user_id is None: | ||
| api100.default_request_headers.clear() | ||
| else: | ||
| api100.set_auth_bearer_token("basic//" + HttpAuthHandler.build_basic_access_token(user_id=user_id)) |
There was a problem hiding this comment.
instead of all this stateful and implicit "set_auth_bearer_token" and "default_request_headers.clear" stuff:
pass the auth headers explicitly with each api100 call
|
@copilot what do you mean? I did list the requested changes in the PR review |
Preflight validation could report a saved user-defined process as unsupported because it ignored the request’s authenticated user.
Drafted with GitHub Copilot assistance.