From d15e4f7cbf9b3eb6b7b350a45b336eb5a327f6d0 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Thu, 15 Jan 2015 17:28:39 -0500 Subject: tests/events_test.py: wrote code to test whether files created in a nested directory properly are split properly to node dirs. --- tests/events_test.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'tests/events_test.py') 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() -- cgit v1.2.3