try to fix storagecounter test in CI
parent
a20222d246
commit
4fbfd89b12
|
@ -19,12 +19,9 @@
|
|||
'''
|
||||
|
||||
import os, json, logger
|
||||
from utils import identifyhome
|
||||
import filepaths
|
||||
|
||||
# set data dir
|
||||
dataDir = identifyhome.identify_home()
|
||||
|
||||
_configfile = os.path.abspath(dataDir + 'config.json')
|
||||
_configfile = filepaths.config_file
|
||||
_config = {}
|
||||
|
||||
def get(key, default = None, save = False):
|
||||
|
|
|
@ -14,6 +14,7 @@ cached_storage = home + 'cachedstorage.dat'
|
|||
announce_cache = home + 'announcecache.dat'
|
||||
export_location = home + 'block-export/'
|
||||
upload_list = home + 'upload-list.json'
|
||||
config_file = home + 'config.json'
|
||||
|
||||
tor_hs_address_file = home + 'hs/hostname'
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@ import sys, os
|
|||
sys.path.append(".")
|
||||
import unittest, uuid
|
||||
|
||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
||||
import config
|
||||
import logger
|
||||
from utils import createdirs
|
||||
import onionrsetup as setup
|
||||
|
@ -13,24 +16,20 @@ import storagecounter
|
|||
import onionrstorage
|
||||
|
||||
def _test_setup():
|
||||
import config
|
||||
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()
|
||||
setup.setup_config()
|
||||
config.reload()
|
||||
|
||||
class TestStorageCounter(unittest.TestCase):
|
||||
def test_basic_amount(self):
|
||||
import config
|
||||
_test_setup()
|
||||
print(config.get('allocations.disk'))
|
||||
|
||||
self.assertIsNotNone(config.get('allocations.disk'))
|
||||
self.assertGreaterEqual(config.get('allocations.disk'), 1000000)
|
||||
|
||||
def test_insert_too_much(self):
|
||||
import config
|
||||
_test_setup()
|
||||
config.set('allocations.disk', 1000)
|
||||
self.assertRaises(onionrexceptions.DiskAllocationReached, onionrblocks.insert, "test")
|
||||
|
|
|
@ -22,6 +22,7 @@ import os, platform
|
|||
def identify_home():
|
||||
|
||||
path = os.environ.get('ONIONR_HOME', None)
|
||||
|
||||
if path is None:
|
||||
system = platform.system()
|
||||
if system == 'Linux':
|
||||
|
@ -36,4 +37,5 @@ def identify_home():
|
|||
path = os.path.abspath(path)
|
||||
if not path.endswith('/'):
|
||||
path += '/'
|
||||
|
||||
return path
|
Loading…
Reference in New Issue