Skip to content

Commit f076c45

Browse files
committed
added test case
1 parent f65f7ba commit f076c45

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_api/test_api_sqla_with_includes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,4 +2871,36 @@ async def test_sort(
28712871
}
28722872

28732873

2874+
class TestFilteringErrors:
2875+
async def test_incorrect_field_name(
2876+
self,
2877+
app: FastAPI,
2878+
client: AsyncClient,
2879+
):
2880+
url = app.url_path_for("get_user_list")
2881+
params = {
2882+
"filter": json.dumps(
2883+
[
2884+
{
2885+
"name": "fake_field_name",
2886+
"op": "eq",
2887+
"val": "",
2888+
},
2889+
],
2890+
),
2891+
}
2892+
response = await client.get(url, params=params)
2893+
assert response.status_code == status.HTTP_400_BAD_REQUEST, response.text
2894+
assert response.json() == {
2895+
"errors": [
2896+
{
2897+
"detail": "UserSchema has no attribute fake_field_name",
2898+
"source": {"parameter": "filters"},
2899+
"status_code": 400,
2900+
"title": "Invalid filters querystring parameter.",
2901+
},
2902+
],
2903+
}
2904+
2905+
28742906
# todo: test errors

0 commit comments

Comments
 (0)