From 80ab84f86f361ebec681f985c7978ed2e1dce3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 26 Jul 2017 15:29:57 +0200 Subject: [PATCH] Fix search, add test --- pymispgalaxies/api.py | 2 +- tests/tests.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pymispgalaxies/api.py b/pymispgalaxies/api.py index f6a3bc0..a49e6bf 100644 --- a/pymispgalaxies/api.py +++ b/pymispgalaxies/api.py @@ -202,7 +202,7 @@ class Cluster(collections.Mapping): def search(self, query): matching = [] - for v in self.values: + for v in self.values.values(): if [s for s in v.searchable if query.lower() in s.lower()]: matching.append(v) return matching diff --git a/tests/tests.py b/tests/tests.py index dd298a3..8c125b4 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -53,3 +53,6 @@ class TestPyMISPGalaxies(unittest.TestCase): def test_print(self): print(self.clusters) + + def test_search(self): + self.assertIsNot(len(self.clusters.search('apt')), 0)