File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def json_datetime_serial(obj):
47
47
OptKey = partial (t .Key , optional = True )
48
48
49
49
50
- SimpleType = t .Int | t .Bool | t .String | t .Float
50
+ SimpleType = t .IntRaw | t .Bool | t .String | t .FloatRaw
51
51
Filter = t .Dict ({
52
52
OptKey ('in' ): t .List (SimpleType ),
53
53
OptKey ('gt' ): SimpleType ,
Original file line number Diff line number Diff line change 6
6
7
7
from aiohttp_admin .exceptions import JsonValidaitonError
8
8
from aiohttp_admin .utils import (validate_query_structure , jsonify ,
9
- validate_payload , as_dict )
9
+ validate_payload , as_dict , SimpleType )
10
10
11
11
12
12
def test_validate_query_empty_defaults ():
@@ -33,6 +33,32 @@ def test_validate_query_all_possible_params():
33
33
assert q == expected
34
34
35
35
36
+ def test_simple_type ():
37
+ assert 42 == SimpleType (42 )
38
+ assert 13.37 == SimpleType (13.37 )
39
+ assert True is SimpleType (True )
40
+ assert 'string' == SimpleType ('string' )
41
+ assert '42' == SimpleType ('42' )
42
+ assert '13.37' == SimpleType ('13.37' )
43
+
44
+
45
+ def test_validate_query_numeric_string ():
46
+ filters = {
47
+ 'views' : "20"
48
+ }
49
+
50
+ query = {'_page' : 1 ,
51
+ '_perPage' : 30 ,
52
+ '_sortField' : 'id' ,
53
+ '_sortDir' : 'DESC' ,
54
+ '_filters' : json .dumps (filters )}
55
+ q = validate_query_structure (query )
56
+
57
+ expected = query .copy ()
58
+ expected ['_filters' ] = filters
59
+ assert q == expected
60
+
61
+
36
62
def test_validate_query_filters_is_not_json ():
37
63
query = {'_filters' : 'foo' }
38
64
You can’t perform that action at this time.
0 commit comments