From cf0507b82da95b52d58f60f1ebd262a69bc0b5b6 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 22 Oct 2020 14:52:49 +0000 Subject: [PATCH] ensure whole tree is made in createdirs --- src/utils/createdirs.py | 2 +- tests/runtime-result.txt | 2 +- tests/test_blocks.py | 13 +++++-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/utils/createdirs.py b/src/utils/createdirs.py index 1c875fa5..add5f920 100644 --- a/src/utils/createdirs.py +++ b/src/utils/createdirs.py @@ -32,7 +32,7 @@ def create_dirs(): filepaths.contacts_location, filepaths.export_location] for path in gen_dirs: if not os.path.exists(path): - os.mkdir(path) + os.makedirs(path) os.chmod(home, stat.S_IRWXU) diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index 703ca349..2dd96424 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1603376389 \ No newline at end of file +1603378318 \ No newline at end of file diff --git a/tests/test_blocks.py b/tests/test_blocks.py index ddf2f5c1..d1915720 100644 --- a/tests/test_blocks.py +++ b/tests/test_blocks.py @@ -7,30 +7,27 @@ import unittest, uuid, hashlib TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) os.environ["ONIONR_HOME"] = TEST_DIR +from utils import createdirs +createdirs.create_dirs() + import onionrblocks import onionrstorage -from utils import createdirs from onionrutils import bytesconverter import onionrcrypto from onionrblocks import onionrblockapi -def setup_test(): - TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' - print("Test directory:", TEST_DIR) - os.environ["ONIONR_HOME"] = TEST_DIR - createdirs.create_dirs() class OnionrBlockTests(unittest.TestCase): def test_plaintext_insert(self): - setup_test() + message = 'hello world' bl = onionrblocks.insert(message) self.assertTrue(bl.startswith('0')) self.assertIn(bytesconverter.str_to_bytes(message), onionrstorage.getData(bl)) def test_encrypted_insert(self): - setup_test() + message = 'hello world2' bl = onionrblocks.insert(message, asymPeer=onionrcrypto.pub_key) self.assertIn(bytesconverter.str_to_bytes(message), onionrblockapi.Block(bl, decrypt=True).bcontent)