Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1512 +/- ##
=======================================
Coverage 96.31% 96.32%
=======================================
Files 50 50
Lines 3831 3833 +2
=======================================
+ Hits 3690 3692 +2
Misses 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Should be rebased on #1523 to game the coverage check |
|
|
||
| def get_plans(self) -> PlanResponse: | ||
| return self._request_and_deserialize("/plans", PlanResponse) | ||
| return self._request_and_deserialize("/api/v1/plans", PlanResponse) |
There was a problem hiding this comment.
def _request_and_deserialize(
self,
suffix: str,
target_type: type[T],
data: Mapping[str, Any] | None = None,
method="GET",
get_exception: Callable[[requests.Response], Exception | None] = _exception,
params: Mapping[str, Any] | None = None,
prefix:str="/api/v1"
) -> T:
url = self._config.url.unicode_string().removesuffix("/") + prefix + suffix
Something like this looks more maintainable ?
This endpoint will need the /api/v1 prefix as well for this to work
There was a problem hiding this comment.
It would make this a smaller change but does bake in the assumption that v1 will always be the default. If we move to v2 being the main version in future we still need to make this change or accept that we will forever be passing prefix="/api/v2" in every call.
This endpoint will need the /api/v1 prefix as well for this to work
Why couldn't the client pass prefix="" when it was called?
There was a problem hiding this comment.
Why couldn't the client pass prefix="" when it was called?
We can but I think this should have also move to /api/v1 for consistency
It would make this a smaller change but does bake in the assumption that v1 will always be the default. If we move to v2 being the main version in future we still need to make this change or accept that we will forever be passing prefix="/api/v2" in every call.
for v2 if the above approach the call will look like prefix="api/v2" ,"/endpoint" instead of "/api/v2/endpoint" which is kind off annoying But can't we do something like this
def _request_and_deserialize(endpoint,prefix="api/v1"):
...
def _request_and_deserialize_v2(endpoint,prefix="api/v2",):
_request_and_deserialize(endpoint,prefix)
...
and call _request_and_deserialize_v2 ?
Personally I like the approach I have mention of using a prefix but I'm not fussed about it
There was a problem hiding this comment.
I have gone with the _request_v1 method approach as it doesn't add extra work down the road when v2 becomes the main API.
There was a problem hiding this comment.
Updated this to be a hybrid between the two. _request_and_deserialize doesn't change behaviour and _request_v1 doesn't have to redefine the whole signature.
2994cde to
d87f06b
Compare
d87f06b to
d06db13
Compare
|
please resolve conflict here |
d06db13 to
18b24c5
Compare
| mock_authn_server.stop() # Cannot use multiple RequestsMock context manager | ||
| mock_get_env = mock_authn_server.get( | ||
| "http://localhost:8000/environment", | ||
| "http://localhost:8000/api/v1/environment", |
There was a problem hiding this comment.
For the CLI it is okay that we are not testing the old endpoints as we are moving cli to exclusively call v1.
But does it have some benefits if we keep testing the old endpoints. Hopefully nothing bad gets pass through our code-reviews
There was a problem hiding this comment.
I have updated test_rest_api to test both old and new routes for the v1 endpoints. I think anything that is testing the client/cli only needs to test the endpoints they are using.
947ef4e to
3fefae3
Compare
ZohebShaikh
left a comment
There was a problem hiding this comment.
Thank you peter, Look good now with the magic tests for per-v1
No description provided.