adjust tests for upload queue exception

master
Kevin Froman 2019-11-27 14:07:51 -06:00
parent f401518d24
commit 13c34a1c04
2 changed files with 11 additions and 6 deletions

View File

@ -4,5 +4,6 @@ test:
- apt-get update -qy - apt-get update -qy
- apt-get install -y python3-pip tor - apt-get install -y python3-pip tor
- pip3 install --require-hashes -r requirements.txt - pip3 install --require-hashes -r requirements.txt
- pip3 install --require-hashes -r requirements-notifications.txt
- python3 --version - python3 --version
- make test - make test

View File

@ -37,10 +37,11 @@ from onionrtypes import UserIDSecretKey
def _check_upload_queue(): def _check_upload_queue():
"""Returns the current upload queue len """Returns the current upload queue len
raises OverflowError if max raises OverflowError if max, false if api not running
""" """
max_upload_queue: int = 5000 max_upload_queue: int = 5000
queue = localcommand.local_command('/gethidden', maxWait=10) queue = localcommand.local_command('/gethidden', maxWait=10)
up_queue = False
try: try:
up_queue = len(queue.splitlines()) up_queue = len(queue.splitlines())
@ -65,6 +66,14 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
our_pub_key = crypto.pub_key our_pub_key = crypto.pub_key
is_offline = True is_offline = True
storage_counter = storagecounter.StorageCounter()
allocationReachedMessage = 'Cannot insert block, disk allocation reached.'
if storage_counter.is_full():
logger.error(allocationReachedMessage)
raise onionrexceptions.DiskAllocationReached
if not _check_upload_queue() is False: is_offline = False if not _check_upload_queue() is False: is_offline = False
if signing_key != '': if signing_key != '':
@ -73,12 +82,7 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
our_pub_key = bytesconverter.bytes_to_str(crypto.cryptoutils.get_pub_key_from_priv(our_private_key)) our_pub_key = bytesconverter.bytes_to_str(crypto.cryptoutils.get_pub_key_from_priv(our_private_key))
use_subprocess = powchoice.use_subprocess(config) use_subprocess = powchoice.use_subprocess(config)
storage_counter = storagecounter.StorageCounter()
allocationReachedMessage = 'Cannot insert block, disk allocation reached.'
if storage_counter.is_full():
logger.error(allocationReachedMessage)
raise onionrexceptions.DiskAllocationReached
retData = False retData = False
if type(data) is None: if type(data) is None: