diff --git a/ereuse_devicehub/resources/device/views.py b/ereuse_devicehub/resources/device/views.py index 2c143517..783d041e 100644 --- a/ereuse_devicehub/resources/device/views.py +++ b/ereuse_devicehub/resources/device/views.py @@ -139,15 +139,15 @@ class DeviceView(View): class ManufacturerView(View): class FindArgs(marshmallow.Schema): - name = marshmallow.fields.Str(required=True, - # Disallow like operators - validate=lambda x: '%' not in x and '_' not in x) + search = marshmallow.fields.Str(required=True, + # Disallow like operators + validate=lambda x: '%' not in x and '_' not in x) @cache(datetime.timedelta(days=1)) def find(self, args: dict): - name = args['name'] + search = args['search'] manufacturers = Manufacturer.query \ - .filter(Manufacturer.name.ilike(name + '%')) \ + .filter(Manufacturer.name.ilike(search + '%')) \ .paginate(page=1, per_page=6) # type: Pagination return jsonify( items=app.resources[Manufacturer.t].schema.dump( diff --git a/tests/test_device.py b/tests/test_device.py index 2ea2d9e1..2c69620b 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -474,7 +474,7 @@ def test_computer_with_display(): def test_manufacturer(user: UserClient): - m, r = user.get(res='Manufacturer', query=[('name', 'asus')]) + m, r = user.get(res='Manufacturer', query=[('search', 'asus')]) assert m == {'items': [{'name': 'Asus', 'url': 'https://en.wikipedia.org/wiki/Asus'}]} assert r.cache_control.public assert r.expires > datetime.datetime.now()