From fd77fe485b89d61ed51b5584afe85ade7745f779 Mon Sep 17 00:00:00 2001 From: Igor Kotrasinski Date: Tue, 26 Jun 2018 14:25:22 +0200 Subject: [PATCH] Don't explicitly quote filter values Fixes #11. Signed-off-by: Igor Kotrasinski --- src/jsonapi_client/filter.py | 2 +- ...ter[title]=__Hep__.json => external__filter[title]=Hep.json} | 0 ...Dippadai__.json => test_leases__filter[title]=Dippadai.json} | 0 tests/test_client.py | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename tests/json/{external__filter[title]=__Hep__.json => external__filter[title]=Hep.json} (100%) rename tests/json/{test_leases__filter[title]=__Dippadai__.json => test_leases__filter[title]=Dippadai.json} (100%) diff --git a/src/jsonapi_client/filter.py b/src/jsonapi_client/filter.py index 48e51db..bc850f5 100644 --- a/src/jsonapi_client/filter.py +++ b/src/jsonapi_client/filter.py @@ -71,5 +71,5 @@ def format_filter_query(self, **kwargs: 'FilterKeywords') -> str: """ def jsonify_key(key): return key.replace('__', '.').replace('_', '-') - return '&'.join(f'filter[{jsonify_key(key)}]="{value}"' + return '&'.join(f'filter[{jsonify_key(key)}]={value}' for key, value in kwargs.items()) diff --git a/tests/json/external__filter[title]=__Hep__.json b/tests/json/external__filter[title]=Hep.json similarity index 100% rename from tests/json/external__filter[title]=__Hep__.json rename to tests/json/external__filter[title]=Hep.json diff --git a/tests/json/test_leases__filter[title]=__Dippadai__.json b/tests/json/test_leases__filter[title]=Dippadai.json similarity index 100% rename from tests/json/test_leases__filter[title]=__Dippadai__.json rename to tests/json/test_leases__filter[title]=Dippadai.json diff --git a/tests/test_client.py b/tests/test_client.py index 70a4b84..f087c3f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -857,7 +857,7 @@ def test_result_filtering(mocked_fetch, api_schema): s = Session('http://localhost:8080/', schema=api_schema) result = s.get('test_leases', Filter(title='Dippadai')) - result2 = s.get('test_leases', Filter(f'filter[title]="Dippadai"')) + result2 = s.get('test_leases', Filter(f'filter[title]=Dippadai')) assert result == result2