691 |
691 |
assert response.json['err'] == 0
|
692 |
692 |
assert len(response.json['data']) == 2
|
693 |
693 |
|
|
694 |
def test_query_builtin_id_filter(app, setup, filetype):
|
|
695 |
csvdata, _url = setup('id,whatever,nom,prenom,sexe', filename=filetype,
|
|
696 |
data=get_file_content(filetype))
|
|
697 |
url = reverse('generic-endpoint', kwargs={
|
|
698 |
'connector': 'csvdatasource',
|
|
699 |
'slug': csvdata.slug,
|
|
700 |
'endpoint': 'query/query-1_/',
|
|
701 |
})
|
|
702 |
|
|
703 |
query = Query(slug='query-1_', resource=csvdata)
|
|
704 |
query.save()
|
|
705 |
|
|
706 |
assert len(app.get(url).json['data']) == 20
|
|
707 |
assert len(app.get(url + '?id=121').json['data']) == 1
|
|
708 |
assert app.get(url + '?id=121').json['data'][0]['prenom'] == 'Eliot'
|
|
709 |
assert app.get(url + '?id=525').json['data'][0]['prenom'] == 'Shanone'
|
|
710 |
|
|
711 |
# check when combined with another filter
|
|
712 |
query.filters = 'sexe == "H"'
|
|
713 |
query.save()
|
|
714 |
assert len(app.get(url).json['data']) == 10
|
|
715 |
assert app.get(url + '?id=121').json['data'][0]['prenom'] == 'Eliot'
|
|
716 |
assert len(app.get(url + '?id=525').json['data']) == 0
|
694 |
717 |
|
695 |
718 |
def test_delete_connector_query(admin_user, app, setup, filetype):
|
696 |
719 |
csvdata, url = setup('id,whatever,nom,prenom,sexe', filename=filetype, data=get_file_content(filetype))
|
697 |
|
-
|