From 7214aa715f76a90e87d5b236b756e2fcfcd00e81 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Mon, 11 Mar 2024 13:31:43 +0100 Subject: [PATCH 1/2] Fix: API - wrong object key in json response when returning errors --- api/api/routes.py | 2 +- api/tests/test_api_cli.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/api/routes.py b/api/api/routes.py index a2c3e1f..4fae7dc 100644 --- a/api/api/routes.py +++ b/api/api/routes.py @@ -49,7 +49,7 @@ def _ask(request_data, validate_captcha=True, access_key=None): access_key=access_key) ok = validator.validate() if not ok: - return jsonify(message=validator.errors), validator.http_return_code + return jsonify(errors=validator.errors), validator.http_return_code # convert amount to wei format amount_wei = Web3.to_wei(validator.amount, 'ether') diff --git a/api/tests/test_api_cli.py b/api/tests/test_api_cli.py index 608dccb..4c39641 100644 --- a/api/tests/test_api_cli.py +++ b/api/tests/test_api_cli.py @@ -59,6 +59,7 @@ def test_ask_route_parameters(self): 'tokenAddress': ERC20_TOKEN_ADDRESS }) self.assertEqual(response.status_code, 429) + self.assertIn('errors', response.get_json().keys()) if __name__ == '__main__': From 463945a194aab212475f51547ac8cd024eec5aec Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Mon, 11 Mar 2024 13:33:17 +0100 Subject: [PATCH 2/2] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9008463..e02514f 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ python3 -m flask --app api run --port 8000 ``` cd api -python3 -m unittest discover tests +python3 -m unittest discover -p 'test_*.py' ``` ### Run Flake8 and isort