From 318acd5a710c151cc850f40c5ceb46ef10e4a7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 6 Nov 2018 15:52:05 +0100 Subject: [PATCH] Replace algorithm list with a tuple --- senpy/api.py | 4 ++-- senpy/blueprints.py | 2 +- tests/test_blueprints.py | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/senpy/api.py b/senpy/api.py index 5d9b8b9..5f20cb1 100644 --- a/senpy/api.py +++ b/senpy/api.py @@ -175,8 +175,8 @@ def parse_params(indict, *specs): parameters=outdict, errors=wrong_params) raise message - if 'algorithm' in outdict and not isinstance(outdict['algorithm'], list): - outdict['algorithm'] = list(outdict['algorithm'].split(',')) + if 'algorithm' in outdict and not isinstance(outdict['algorithm'], tuple): + outdict['algorithm'] = tuple(outdict['algorithm'].split(',')) return outdict diff --git a/senpy/blueprints.py b/senpy/blueprints.py index 33598d7..8fc696f 100644 --- a/senpy/blueprints.py +++ b/senpy/blueprints.py @@ -196,7 +196,7 @@ def api_root(plugin): if plugin: plugin = plugin.replace('+', '/') plugin = plugin.split('/') - req.parameters['algorithm'] = plugin + req.parameters['algorithm'] = tuple(plugin) return current_app.senpy.analyse(req) diff --git a/tests/test_blueprints.py b/tests/test_blueprints.py index ebe523d..51a11e2 100644 --- a/tests/test_blueprints.py +++ b/tests/test_blueprints.py @@ -74,6 +74,7 @@ class BlueprintsTest(TestCase): The results for a POST request should be the same as for a GET request. """ resp = self.client.post("/api/", data={'i': 'My aloha mohame', + 'algorithm': 'rand', 'with_parameters': True}) self.assertCode(resp, 200) js = parse_resp(resp)