From 24eb6541326111f58b750f5be116dc66ce072bd5 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 28 Jan 2015 11:21:49 -0500 Subject: 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. --- tests/events_test.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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) -- cgit v1.2.3