Skip to content

Commit f0c5026

Browse files
committed
add 1 test case, now 55 test cases for apijson-get
1 parent dda827b commit f0c5026

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/test.py

+18
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,24 @@ def test_apijson_get():
743743
>>> print(d)
744744
{'code': 400, 'msg': "model does not have this column: 'nonexist'"}
745745
746+
>>> #query array with a nonexist column
747+
>>> data ='''{
748+
... "[]":{
749+
... "@count":4,
750+
... "@page":0,
751+
... "user":{
752+
... "@column":"id,username,nickname,email",
753+
... "@order":"id-",
754+
... "@role":"ADMIN",
755+
... "nonexist":1
756+
... }
757+
... }
758+
... }'''
759+
>>> r = handler.post('/apijson/get', data=data, pre_call=pre_call_as("admin"), middlewares=[])
760+
>>> d = json_loads(r.data)
761+
>>> print(d)
762+
{'code': 400, 'msg': "non-existent column or not support item: 'nonexist'"}
763+
746764
>>> #Association query: Two tables, one to one,ref path is absolute path
747765
>>> data ='''{
748766
... "moment":{},

uliweb_apijson/apijson/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _get_filter_condition(self,model,model_param,item,expr=False):
254254
elif hasattr(model,n):
255255
return getattr(model.c,n)==model_param[n]
256256
else:
257-
raise UliwebError("not support item: '%s'"%(item))
257+
raise UliwebError("non-existent column or not support item: '%s'"%(item))
258258

259259
def head(self):
260260
try:

0 commit comments

Comments
 (0)