summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-09-29 14:15:49 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-09-29 14:15:49 -0400
commit54d70dad75387e0369c2b67dacff80d32d3cfc1e (patch)
treeb440706df3bd3c08fc6dd20ceeb5ab2a29a76c35 /tests
parent6171a67bb57f5ac10b43da785fe24aeb83fbd609 (diff)
[bug fix] fix for :b#2:
Now combox ignores tmp files created by editors. modified: TODO.org modified: combox/events.py modified: tests/events_test.py modified: tests/utils.py
Diffstat (limited to 'tests')
-rw-r--r--tests/events_test.py15
-rw-r--r--tests/utils.py12
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index 16467b2..7daabff 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -42,7 +42,7 @@ from combox.file import (relative_path, purge_dir, hash_file,
from combox.silo import ComboxSilo
from tests.utils import (get_config, shardedp, dirp, renamedp,
path_deletedp, rm_nodedirs, rm_configdir,
- purge_nodedirs, purge)
+ purge_nodedirs, purge, not_shardedp)
class TestEvents(object):
@@ -94,6 +94,19 @@ class TestEvents(object):
silo = ComboxSilo(self.config, self.silo_lock)
assert silo.exists(self.TEST_FILE_COPY_0)
+ # Test - tmp file creation.
+ # combox must ignore it.
+ self.TEST_TMP_FILE = "%s~" % self.TEST_FILE
+ copyfile(self.TEST_FILE, self.TEST_TMP_FILE)
+ # wait for a second.
+ time.sleep(1)
+ ## confirm that shards were not created.
+ not_shardedp(self.TEST_TMP_FILE)
+ ## confirm that it did not get registered in the silo.
+ assert not silo.exists(self.TEST_TMP_FILE)
+ # purge it later.
+ self.purge_list.append(self.TEST_TMP_FILE)
+
# Test - File deletion.
remove(self.TEST_FILE_COPY_0)
time.sleep(1)
diff --git a/tests/utils.py b/tests/utils.py
index dc7a309..3f46813 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -109,6 +109,18 @@ def shardedp(f):
assert path.exists(shard) and path.isfile(shard)
+def not_shardedp(f):
+ """Checks if file's shards does not exists in the node directories"""
+ config = get_config()
+ nodes = get_nodedirs(config)
+ i = 0
+ for node in nodes:
+ rel_path = relative_path(f, config)
+ shard = "%s.shard%s" % (path.join(node, rel_path), i)
+ i += 1
+ assert not path.exists(shard) and not path.isfile(shard)
+
+
def dirp(d):
"""
Checks if the directory was created under node directories