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