diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-16 09:26:55 -0500 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-16 09:26:55 -0500 |
commit | cba72d5cf6b7a1a2c96a0512929ba8d1cfda02e8 (patch) | |
tree | 8c47dee034759844c9b1717aead1bed37ecdbd8b | |
parent | 8b6d506f932e1809a71593b5b951e7c74e898c8f (diff) |
tests/events_test.py: wrote test for file/directory rename under combox directory.
-rw-r--r-- | tests/events_test.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/events_test.py b/tests/events_test.py index f143c9e..8dce21c 100644 --- a/tests/events_test.py +++ b/tests/events_test.py @@ -65,6 +65,34 @@ def dirp(d): directory = path.join(node, rel_path) assert path.isdir(directory) +def renamedp(old_p, new_p): + """ + Checks if the file shards or directory were/was renamed in the under the node directories. + + old_p: old path to directory or file under combox directory. + new_p: new (present) path to the directory or file under combox directory. + """ + + nodes = get_nodedirs(config) + + is_dir = True if path.isdir(new_p) else False + i = 0 + + for node in nodes: + old_rel_path = relative_path(old_p, config) + new_rel_path = relative_path(new_p, config) + + if is_dir: + old_path = path.join(node, old_rel_path) + new_path = path.join(node, new_rel_path) + else: + old_path = "%s.shard%s" % (path.join(node, old_rel_path), i) + new_path = "%s.shard%s" % (path.join(node, new_rel_path), i) + i += 1 + + assert not path.exists(old_path) + assert path.exists(new_path) + def path_deletedp(p): """ @@ -133,6 +161,15 @@ def test_CEH(): time.sleep(1) shardedp(TEST_FILE_COPY_1) + # Test - dir rename + TEST_DIR_1_NEW = path.join(path.dirname(TEST_DIR_1), + 'snafu') + TEST_FILE_COPY_1_NEW = path.join(TEST_DIR_1_NEW, path.basename(TEST_FILE)) + os.rename(TEST_DIR_1, TEST_DIR_1_NEW) + time.sleep(1) + renamedp(TEST_DIR_1, TEST_DIR_1_NEW) + renamedp(TEST_FILE_COPY_1, TEST_FILE_COPY_1_NEW) + # Test directory & file deletion purge_dir(TEST_DIR_0) # remove the directory itself. |