combox

split and encrypted files between online file storage providers
git clone git://git.ricketyspace.net/combox.git
Log | Files | Refs

commit 51b7feef964f77d589fd9e305f4de3f9cf88fb83
parent 7c612e9520aa7d1c41e0aa9eafc0cf00cebb7180
Author: Siddharth Ravikumar <sravik@bgsu.edu>
Date:   Wed,  4 Mar 2015 20:49:31 -0500

new function combox.file.mk_dir

wrote test for it too.

	modified:   combox/file.py
	modified:   tests/file_test.py

Diffstat:
combox/file.py | 8++++++++
tests/file_test.py | 22++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/combox/file.py b/combox/file.py @@ -110,6 +110,14 @@ def mk_nodedir(directory, config): print e, "Something wrong. report bug to sravik@bgsu.edu" +def mk_dir(directory): + """Creates directory""" + try: + os.mkdir(directory) + except OSError, e: + print e, "Something wrong. report bug to sravik@bgsu.edu" + + def rm_nodedir(directory, config): """ Removes directory `directory' inside the nodes. diff --git a/tests/file_test.py b/tests/file_test.py @@ -42,6 +42,10 @@ class TestFile(object): FILES_DIR = self.config['combox_dir'] self.TEST_FILE = path.join(FILES_DIR,'the-red-star.jpg') + # files that have to be removed at the end of this test class + # should be appended to this list. + self.purge_list = [] + def test_split(self): """Test to split, glue and create a copy of the image file from the @@ -160,6 +164,17 @@ class TestFile(object): assert not path.isdir(new_dir) + def test_mkdir(self): + """Tests mk_dir function.""" + new_dir = path.join(self.config['combox_dir'], 'barius') + mk_dir(new_dir) + + assert path.isdir(new_dir) + + # add it to purge list + self.purge_list.append(new_dir) + + @classmethod def teardown_class(self): """Purge the mess created by this test.""" @@ -167,3 +182,10 @@ class TestFile(object): rm_shards(self.TEST_FILE, self.config) rm_nodedirs(self.config) rm_configdir() + + for f in self.purge_list: + if path.exists(f) and path.isfile(f): + os.remove(f) + elif path.exists(f) and path.isdir(f): + purge_dir(f) + os.rmdir(f)