aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-10-13 11:18:59 +0200
committerMilo Casagrande <milo.casagrande@linaro.org>2014-10-13 11:18:59 +0200
commitb668eb44557ba2bb8239f5abd4a9b4ffcf4d38ae (patch)
treeafb71d66df9128d11937fb9c7d4d5f9335d41d4b
parentb5d5877cf4100a7e2ed080835b3b9ceea0980ed6 (diff)
batch: Store results in a list instead of a set.
* Instead of storing the result in a set, store them in a list making sure the list is made of unique elements. Change-Id: If623112faa03245debfb925ed47ee33cb61fc9a7
-rw-r--r--app/utils/batch/common.py7
-rw-r--r--app/utils/batch/tests/test_batch_common.py10
2 files changed, 9 insertions, 8 deletions
diff --git a/app/utils/batch/common.py b/app/utils/batch/common.py
index 562353c..d3e537a 100644
--- a/app/utils/batch/common.py
+++ b/app/utils/batch/common.py
@@ -94,7 +94,7 @@ def get_batch_query_args(query):
:param query: The query string to analyze.
:type query: string
:return A dictionary with keys the keys from the query, and values the
- values stored in a set.
+ values stored in a list.
"""
args = {}
@@ -110,8 +110,9 @@ def get_batch_query_args(query):
# key=value.
if len(arg) > 1:
if args.get(arg[0], None):
- args[arg[0]].add(arg[1])
+ args[arg[0]].append(arg[1])
else:
- args[arg[0]] = set([arg[1]])
+ args[arg[0]] = list([arg[1]])
+ args[arg[0]] = list(set(args[arg[0]]))
return args
diff --git a/app/utils/batch/tests/test_batch_common.py b/app/utils/batch/tests/test_batch_common.py
index 1aed5c6..922ac3d 100644
--- a/app/utils/batch/tests/test_batch_common.py
+++ b/app/utils/batch/tests/test_batch_common.py
@@ -35,7 +35,7 @@ class TestBatch(unittest.TestCase):
def test_get_batch_query_base_case(self):
query = "?foo=bar"
- expected = {"foo": set(["bar"])}
+ expected = {"foo": ["bar"]}
self.assertEqual(expected, get_batch_query_args(query))
@@ -46,25 +46,25 @@ class TestBatch(unittest.TestCase):
def test_get_batch_query_base_case_wrong_and_correct(self):
query = "?foo&bar=foo"
- expected = {"bar": set(["foo"])}
+ expected = {"bar": ["foo"]}
self.assertEqual(expected, get_batch_query_args(query))
def test_get_batch_query_simple_with_question(self):
query = "?foo=bar&bar=foo"
- expected = {"bar": set(["foo"]), "foo": set(["bar"])}
+ expected = {"bar": ["foo"], "foo": ["bar"]}
self.assertEqual(expected, get_batch_query_args(query))
def test_get_batch_query_simple_no_question(self):
query = "foo=bar&bar=foo"
- expected = {"bar": set(["foo"]), "foo": set(["bar"])}
+ expected = {"bar": ["foo"], "foo": ["bar"]}
self.assertEqual(expected, get_batch_query_args(query))
def test_get_batch_query_multiple_values(self):
query = "bar=foo&foo=bar&bar=foo&foo=baz&bar=foo"
- expected = {"bar": set(["foo"]), "foo": set(["bar", "baz"])}
+ expected = {"foo": ["baz", "bar"], "bar": ["foo"]}
self.assertEqual(expected, get_batch_query_args(query))