Skip to content

Commit

Permalink
fix tags filter to retrieve specified tags not excluding specified ta…
Browse files Browse the repository at this point in the history
…gs (#34)

* fix tags filter to retrieve specified tags not excluding specified tags

* fix tests and return value when filters is empty
  • Loading branch information
José Carlos Ferreiro authored and sekipaolo committed Oct 10, 2017
1 parent d7cf6da commit d517b3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pypingdom/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def get_check(self, name=None, _id=None):

def get_checks(self, filters=None):
if filters is None:
filters = {}
return [c for c in self.checks.values() if len(set(filters.get("tags", [])).intersection(set([x['name']
return [c for c in self.checks.values()]
return [c for c in self.checks.values() if not len(set(filters.get("tags", [])).intersection(set([x['name']
for x in c.tags]))) == 0]

def create_check(self, name, obj):
Expand Down
2 changes: 1 addition & 1 deletion pypingdom/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def test_get_checks(self, m):
self.assertTrue(all(isinstance(x, Check) for x in res))

res = client.get_checks(filters={"tags": ['apache']})
self.assertEqual(len(res), 2)
self.assertEqual(len(res), 1)

0 comments on commit d517b3e

Please sign in to comment.