File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -2871,4 +2871,36 @@ async def test_sort(
2871
2871
}
2872
2872
2873
2873
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
+
2874
2906
# todo: test errors
You can’t perform that action at this time.
0 commit comments