summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPatrick Maia and Victor Shyba <pixelated-team+pmaia+vshyba@thoughtworks.com>2014-09-07 17:05:02 +0000
committerPatrick Maia <pmaia@thoughtworks.com>2014-09-07 17:05:02 +0000
commit2b04f7a243b2c8c68f45dd60efdc5c38249ac220 (patch)
tree72df2a1fad6d44adcdca5bf51a0b7c96005f010b /service
parent49dfdf8ad54860ba5b518681f17574b86054d384 (diff)
#51 - adds method TagIndex.empty
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/tag_index.py3
-rw-r--r--service/test/adapter/tag_index_test.py7
2 files changed, 10 insertions, 0 deletions
diff --git a/service/pixelated/adapter/tag_index.py b/service/pixelated/adapter/tag_index.py
index ea69be1a..bac3c6a6 100644
--- a/service/pixelated/adapter/tag_index.py
+++ b/service/pixelated/adapter/tag_index.py
@@ -44,6 +44,9 @@ class TagIndex:
else:
return None
+ def empty(self):
+ return len(self.db.keys()) == 0
+
def values(self):
return set(self.get(key) for key in self.db.keys())
diff --git a/service/test/adapter/tag_index_test.py b/service/test/adapter/tag_index_test.py
index 05f7ce55..525bf0d6 100644
--- a/service/test/adapter/tag_index_test.py
+++ b/service/test/adapter/tag_index_test.py
@@ -61,3 +61,10 @@ class TestTagIndex(unittest.TestCase):
self.tag_index.add(same_name_tag)
self.assertEquals(True, self.tag_index.get('tag').default)
+
+ def test_empty_returns_true_if_there_are_no_values(self):
+ self.assertTrue(self.tag_index.empty())
+
+ def test_empty_returns_false_if_there_are_values(self):
+ self.tag_index.set(Tag('tag'))
+ self.assertFalse(self.tag_index.empty())