From 7dbd4907a7b351bcc022a55068449c987d1754df Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Thu, 19 Mar 2015 22:42:26 -0400 Subject: new function combox.file.node_paths: returns the abs. path of shards/directories in node directories. modified: combox/file.py modified: tests/file_test.py --- tests/file_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/file_test.py b/tests/file_test.py index 6517943..bd81fd7 100644 --- a/tests/file_test.py +++ b/tests/file_test.py @@ -157,6 +157,35 @@ class TestFile(object): isfile=False) + def test_nodepaths(self): + """Tests the node_paths function.""" + nodes = get_nodedirs(self.config) + node_iter = iter(nodes) + + # test for file shards + foo = path.join(self.config['combox_dir'], 'foo.txt') + foo_rel_path = relative_path(foo, self.config) + foo_shards = node_paths(foo, self.config, True) + + shard_no = 0 + for foo_shard in foo_shards: + file_shard = '%s.shard%d' % (foo_rel_path, shard_no) + n_path = path.join(node_iter.next(), file_shard) + assert_equal(n_path, foo_shard) + shard_no += 1 + + # test for directory inside node_directories + bar = path.join(self.config['combox_dir'], 'bar') + bar_rel_path = relative_path(bar, self.config) + bar_n_paths = node_paths(bar, self.config, False) + + + node_iter = iter(nodes) + for bar_n_path in bar_n_paths: + b_n_path = path.join(node_iter.next(), bar_rel_path) + assert_equal(b_n_path, bar_n_path) + + def test_rmpath(self): """Tests rm_path function""" new_dir = path.join(self.config['combox_dir'], 'fooius') -- cgit v1.2.3