Skip to content

Commit 05106a4

Browse files
author
huangzhuo
committed
Modify testcase
1. delete sort relationship exception 2. add a case to test get list with relationship sort queryparams
1 parent a17d9e7 commit 05106a4

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

tests/test_sqlalchemy_data_layer.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ def test_query_string_manager(person_schema):
389389
qsm = QSManager(query_string, person_schema)
390390
with pytest.raises(BadRequest):
391391
qsm.pagination
392-
qsm.qs['sort'] = 'computers'
393-
with pytest.raises(InvalidSort):
394-
qsm.sorting
392+
#qsm.qs['sort'] = 'computers'
393+
#with pytest.raises(InvalidSort):
394+
#qsm.sorting
395395

396396

397397
def test_resource(app, person_model, person_schema, session, monkeypatch):
@@ -474,6 +474,46 @@ def test_get_list(client, register_routes, person, person_2):
474474
response = client.get('/persons' + '?' + querystring, content_type='application/vnd.api+json')
475475
assert response.status_code == 200
476476

477+
def test_get_list_sort_relationship(client, register_routes, person, person_2):
478+
with client:
479+
querystring = urlencode({'page[number]': 1,
480+
'page[size]': 1,
481+
'fields[person]': 'name,birth_date',
482+
'sort': '-computers',
483+
'include': 'computers.owner',
484+
'filter': json.dumps(
485+
[
486+
{
487+
'and': [
488+
{
489+
'name': 'computers',
490+
'op': 'any',
491+
'val': {
492+
'name': 'serial',
493+
'op': 'eq',
494+
'val': '0000'
495+
}
496+
},
497+
{
498+
'or': [
499+
{
500+
'name': 'name',
501+
'op': 'like',
502+
'val': '%test%'
503+
},
504+
{
505+
'name': 'name',
506+
'op': 'like',
507+
'val': '%test2%'
508+
}
509+
]
510+
}
511+
]
512+
}
513+
])})
514+
response = client.get('/persons' + '?' + querystring, content_type='application/vnd.api+json')
515+
assert response.status_code == 200
516+
477517

478518
def test_get_list_disable_pagination(client, register_routes):
479519
with client:

0 commit comments

Comments
 (0)