summaryrefslogtreecommitdiffstats
path: root/tests/events_test.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-01-28 11:21:49 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-01-28 11:21:49 -0500
commit24eb6541326111f58b750f5be116dc66ce072bd5 (patch)
tree1b7973db9c4b73ad4cd59d71f5d3e7296ec459bc /tests/events_test.py
parent27e46c36acb6a8465af4c20812c8a8ed7c61d5ba (diff)
tests/events_test.py: wrote test for 'file modification' under test_housekeep()
This, I guess, completes the tests for the new housekeep method in the ComboxDirMonitor class.
Diffstat (limited to 'tests/events_test.py')
-rw-r--r--tests/events_test.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index 5c726d9..b0d7cc6 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -245,6 +245,8 @@ def test_CDM():
def test_housekeep():
"""ComboxDirMonitor's housekeep method test."""
+ # test file deletion and addition
+
lorem = path.join(FILES_DIR, 'lorem.txt')
lorem_moved = path.join(FILES_DIR, 'lorem.moved.txt')
os.rename(lorem, lorem_moved)
@@ -260,3 +262,29 @@ def test_housekeep():
os.rename(lorem_moved, lorem)
rm_shards(lorem_moved, config)
silo.remove(lorem_moved)
+
+ # test file modification
+
+ lorem_ipsum = path.join(FILES_DIR, 'lorem.ipsum.txt')
+ copyfile(lorem, lorem_ipsum)
+ assert path.exists(lorem_ipsum)
+
+ cdm = ComboxDirMonitor(config)
+ cdm.housekeep()
+
+ silo = ComboxSilo(config)
+ assert silo.exists(lorem_ipsum)
+
+ ipsum = path.join(FILES_DIR, "ipsum.txt")
+ ipsum_content = read_file(ipsum)
+
+ lorem_ipsum_content = read_file(lorem_ipsum)
+ lorem_ipsum_content = "%s\n%s" % (lorem_ipsum_content, ipsum_content)
+ write_file(lorem_ipsum, lorem_ipsum_content)
+
+ cdm.housekeep()
+
+ silo = ComboxSilo(config)
+ assert not silo.stale(lorem_ipsum)
+ os.remove(lorem_ipsum)
+ silo.remove(lorem_ipsum)