From 1217539f47c923a22434e05eaa9e271696c6a637 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Thu, 26 Feb 2015 22:44:58 -0500 Subject: fleshed out the NodeDirMonitor's on_modified method + wrote tests for it. modified: combox/events.py modified: tests/events_test.py --- tests/events_test.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/events_test.py b/tests/events_test.py index c62d3f2..f645e75 100644 --- a/tests/events_test.py +++ b/tests/events_test.py @@ -266,6 +266,40 @@ class TestEvents(object): self.purge_list.append(self.TEST_FILE_MUTANT) self.purge_list.append(self.FOO_DIR) + # Test - shard modification + self.lorem_file = path.join(self.FILES_DIR, 'lorem.txt') + lorem_content = read_file(self.lorem_file) + self.lorem_file_copy = "%s.copy" % self.lorem_file + + copyfile(self.lorem_file, self.lorem_file_copy) + split_and_encrypt(self.lorem_file_copy, self.config, + lorem_content) + + silo = ComboxSilo(self.config) + silo.update(self.lorem_file_copy) + shardedp(self.lorem_file_copy) + + silo = ComboxSilo(self.config) + lorem_file_copy_hash = silo.db.get(self.lorem_file_copy) + + self.ipsum_file = path.join(self.FILES_DIR, 'ipsum.txt') + ipsum_content = read_file(self.ipsum_file) + lorem_copy_content = "%s\n%s" % (lorem_content, ipsum_content) + + split_and_encrypt(self.lorem_file_copy, self.config, + lorem_copy_content) + time.sleep(1) + ## check if the lorem_file_copy's info is updated in silo + silo = ComboxSilo(self.config) + + assert lorem_copy_content == read_file(self.lorem_file_copy) + assert lorem_file_copy_hash != silo.db.get(self.lorem_file_copy) + + self.purge_list.append(self.lorem_file_copy) + + observer.stop() + observer.join() + def teardown(self): """Cleans up things after each test in this class""" -- cgit v1.2.3