diff options
-rw-r--r-- | service/pixelated/adapter/tag_index.py | 4 | ||||
-rw-r--r-- | service/test/adapter/tag_index_test.py | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/service/pixelated/adapter/tag_index.py b/service/pixelated/adapter/tag_index.py index bac3c6a6..743c74e1 100644 --- a/service/pixelated/adapter/tag_index.py +++ b/service/pixelated/adapter/tag_index.py @@ -44,6 +44,10 @@ class TagIndex: else: return None + def remove(self, tag_name): + if tag_name in self.db: + del self.db[tag_name] + def empty(self): return len(self.db.keys()) == 0 diff --git a/service/test/adapter/tag_index_test.py b/service/test/adapter/tag_index_test.py index 525bf0d6..7667e8e2 100644 --- a/service/test/adapter/tag_index_test.py +++ b/service/test/adapter/tag_index_test.py @@ -68,3 +68,11 @@ class TestTagIndex(unittest.TestCase): def test_empty_returns_false_if_there_are_values(self): self.tag_index.set(Tag('tag')) self.assertFalse(self.tag_index.empty()) + + def test_remove_deletes_the_tag_with_the_given_key_from_the_index(self): + self.tag_index.set(Tag('tag')) + self.tag_index.remove('tag') + self.assertEquals(None, self.tag_index.get('tag')) + + def test_remove_does_not_raises_exception_if_key_is_not_present(self): + self.tag_index.remove('not_there') |