summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--combox/silo.py18
-rw-r--r--tests/silo_test.py15
2 files changed, 33 insertions, 0 deletions
diff --git a/combox/silo.py b/combox/silo.py
index 38de523..0968d12 100644
--- a/combox/silo.py
+++ b/combox/silo.py
@@ -176,3 +176,21 @@ class ComboxSilo(object):
except KeyError, e:
# file_ info not there under type_ dict.
return None
+
+
+ def node_rem(self, type_, file_):
+ """
+ Removes information about the shard of `file_'.
+
+ type_: 'file_created', 'file_modified', 'file_moved', 'file_deleted'
+ file_: path of the file_ in combox directory.
+ """
+
+ self.reload()
+ with self.lock:
+ try:
+ return self.db.dpop(type_, file_)
+ except KeyError, e:
+ # means file_'s info was already removed.
+ # do nothing
+ pass
diff --git a/tests/silo_test.py b/tests/silo_test.py
index 067dd51..983ef1b 100644
--- a/tests/silo_test.py
+++ b/tests/silo_test.py
@@ -198,6 +198,21 @@ class TestSilo(object):
assert_equal(2, silo.node_get('file_created', self.LOREM))
+ def test_csilo_noderem(self):
+ """Tests node_rem method in ComboxSilo class
+ """
+ silo = ComboxSilo(self.config, self.silo_lock)
+
+ silo.node_set('file_created', self.LOREM)
+ silo.node_set('file_created', self.LOREM)
+ silo.node_set('file_created', self.LOREM)
+ silo.node_set('file_created', self.LOREM)
+ assert_equal(4, silo.node_get('file_created', self.LOREM))
+
+ removed = silo.node_rem('file_created', self.LOREM)
+ assert_equal(True, removed)
+ assert_equal(None, silo.node_get('file_created', self.LOREM))
+
def teardown(self):
"""Cleans up things after each test in this class"""