summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-01-15 17:28:39 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-01-15 17:28:39 -0500
commitd15e4f7cbf9b3eb6b7b350a45b336eb5a327f6d0 (patch)
tree847499177c30b7c127e8d9c744f090132f3dda09 /tests
parentc04f52356574387c133635025fe8f65127d79427 (diff)
tests/events_test.py: wrote code to test whether files created in a nested directory properly are split properly to node dirs.
Diffstat (limited to 'tests')
-rw-r--r--tests/events_test.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index 828f944..8acd7d3 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -29,7 +29,7 @@ from watchdog.observers import Observer
from combox.events import ComboxEventHandler
from combox.config import get_nodedirs
-from combox.file import relative_path
+from combox.file import relative_path, purge_dir
CONFIG_DIR = path.join('tests', 'test-config')
@@ -77,14 +77,14 @@ def test_CEH():
observer.start()
# Test - new file addition
- TEST_FILE_COPY = "%s.mutant" % TEST_FILE
- copyfile(TEST_FILE, TEST_FILE_COPY)
+ TEST_FILE_COPY_0 = "%s.mutant" % TEST_FILE
+ copyfile(TEST_FILE, TEST_FILE_COPY_0)
## wait for ComboxEventHandler to split and scatter the file in the
## node directories.
time.sleep(1)
## check if the shards were created.
- shardedp(TEST_FILE_COPY)
- remove(TEST_FILE_COPY)
+ shardedp(TEST_FILE_COPY_0)
+ remove(TEST_FILE_COPY_0)
# Test - directory creation
TEST_DIR_0 = path.join(FILES_DIR, 'foo')
@@ -99,5 +99,17 @@ def test_CEH():
## check if TEST_DIR_1 is created under node directories.
dirp(TEST_DIR_1)
+ # Test - new file in a nested directory
+ TEST_FILE_COPY_1 = path.join(TEST_DIR_1, path.basename(TEST_FILE))
+ copyfile(TEST_FILE, TEST_FILE_COPY_1)
+ time.sleep(1)
+ shardedp(TEST_FILE_COPY_1)
+ remove(TEST_FILE_COPY_1)
+ # purge nested dir TEST_DIR_0
+ purge_dir(TEST_DIR_0)
+ # remove the directory itself.
+ os.rmdir(TEST_DIR_0)
+ time.sleep(2)
+
observer.stop()
observer.join()