ensure whole tree is made in createdirs

master
Kevin Froman 2020-10-22 14:52:49 +00:00
parent 862b39c217
commit cf0507b82d
3 changed files with 7 additions and 10 deletions

View File

@ -32,7 +32,7 @@ def create_dirs():
filepaths.contacts_location, filepaths.export_location] filepaths.contacts_location, filepaths.export_location]
for path in gen_dirs: for path in gen_dirs:
if not os.path.exists(path): if not os.path.exists(path):
os.mkdir(path) os.makedirs(path)
os.chmod(home, stat.S_IRWXU) os.chmod(home, stat.S_IRWXU)

View File

@ -1 +1 @@
1603376389 1603378318

View File

@ -7,30 +7,27 @@ import unittest, uuid, hashlib
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
print("Test directory:", TEST_DIR) print("Test directory:", TEST_DIR)
os.environ["ONIONR_HOME"] = TEST_DIR os.environ["ONIONR_HOME"] = TEST_DIR
from utils import createdirs
createdirs.create_dirs()
import onionrblocks import onionrblocks
import onionrstorage import onionrstorage
from utils import createdirs
from onionrutils import bytesconverter from onionrutils import bytesconverter
import onionrcrypto import onionrcrypto
from onionrblocks import onionrblockapi 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): class OnionrBlockTests(unittest.TestCase):
def test_plaintext_insert(self): def test_plaintext_insert(self):
setup_test()
message = 'hello world' message = 'hello world'
bl = onionrblocks.insert(message) bl = onionrblocks.insert(message)
self.assertTrue(bl.startswith('0')) self.assertTrue(bl.startswith('0'))
self.assertIn(bytesconverter.str_to_bytes(message), onionrstorage.getData(bl)) self.assertIn(bytesconverter.str_to_bytes(message), onionrstorage.getData(bl))
def test_encrypted_insert(self): def test_encrypted_insert(self):
setup_test()
message = 'hello world2' message = 'hello world2'
bl = onionrblocks.insert(message, asymPeer=onionrcrypto.pub_key) bl = onionrblocks.insert(message, asymPeer=onionrcrypto.pub_key)
self.assertIn(bytesconverter.str_to_bytes(message), onionrblockapi.Block(bl, decrypt=True).bcontent) self.assertIn(bytesconverter.str_to_bytes(message), onionrblockapi.Block(bl, decrypt=True).bcontent)