Commit 1602b14
authored
[MPT-18938] Added render() as queryable mixin (#226)
This pull request introduces support for a new `render()` query
parameter in the API client, allowing users to request rendered output
in their queries. The implementation includes updates to the core
query-building logic, a new method for chaining `render()` into queries,
and comprehensive tests to ensure correctness.
Enhancements to query parameter handling:
* Added a `with_render` boolean option to the `QueryState` class,
allowing the inclusion of the `render()` parameter in the query string
when building API requests. (`mpt_api_client/http/query_state.py`)
[[1]](diffhunk://#diff-1d40a2820baa57fd0d1a32181811a6269490c4ebe0d01a81e2092753e230a035R20-R34)
[[2]](diffhunk://#diff-1d40a2820baa57fd0d1a32181811a6269490c4ebe0d01a81e2092753e230a035R51-R55)
[[3]](diffhunk://#diff-1d40a2820baa57fd0d1a32181811a6269490c4ebe0d01a81e2092753e230a035R78-R84)
* Introduced the `with_render()` method in `QueryableMixin`, enabling
method chaining to easily add the `render()` parameter to queries.
(`mpt_api_client/http/mixins/queryable_mixin.py`)
Testing and validation:
* Added end-to-end tests for both async and sync clients to verify that
records returned with `render()` do not contain template characters and
that the correct object is returned.
(`tests/e2e/audit/records/test_async_records.py`,
`tests/e2e/audit/records/test_sync_records.py`)
[[1]](diffhunk://#diff-d5824e2487473d7b2d7b6d429cb542a344a8e292af159e30c2db414e273507c4R45-R55)
[[2]](diffhunk://#diff-485960b9be8eac93a315313579525f281be8ed7106f8364dfb5ce40c83e43f11R46-R56)
* Created unit tests for the new `with_render()` method and for query
string building with and without `render()`.
(`tests/unit/http/mixins/test_queryable_mixin.py`,
`tests/unit/http/test_query_state.py`)
[[1]](diffhunk://#diff-e42182fb74793b73637a4e1d86903f0c68b5bc2ab85edb80c2d8cb413df329a6R81-R88)
[[2]](diffhunk://#diff-1e8de208c42e77b791fcd52302bf69b5cb1cbd4107cc40e320015c08425b0964R26)
[[3]](diffhunk://#diff-1e8de208c42e77b791fcd52302bf69b5cb1cbd4107cc40e320015c08425b0964R38-R55)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
Closes [MPT-18938](https://softwareone.atlassian.net/browse/MPT-18938)
- Add support for requesting rendered output via a render() query
parameter
- Extend QueryState with a with_render flag/property; QueryState.build()
appends render() when enabled
- Add with_render() to QueryableMixin to enable chaining render() into
queries and propagate the flag through filter/order_by/select
- Add unit tests for QueryState.with_render and QueryableMixin chaining
behavior
- Add sync and async end-to-end tests verifying rendered records contain
no template delimiters and return the expected objects
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
[MPT-18938]:
https://softwareone.atlassian.net/browse/MPT-18938?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQFile tree
6 files changed
+84
-0
lines changed- mpt_api_client/http
- mixins
- tests
- e2e/audit/records
- unit/http
- mixins
6 files changed
+84
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
63 | 81 | | |
64 | 82 | | |
65 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
47 | 56 | | |
48 | 57 | | |
49 | 58 | | |
| |||
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| 84 | + | |
72 | 85 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
37 | 56 | | |
38 | 57 | | |
39 | 58 | | |
| |||
0 commit comments