From 13c34a1c04bb1b4417c46216c46fa42a390d246a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 27 Nov 2019 14:07:51 -0600 Subject: [PATCH] adjust tests for upload queue exception --- .gitlab-ci.yml | 1 + src/onionrblocks/insert.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 48f54da0..a2249366 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,5 +4,6 @@ test: - apt-get update -qy - apt-get install -y python3-pip tor - pip3 install --require-hashes -r requirements.txt + - pip3 install --require-hashes -r requirements-notifications.txt - python3 --version - make test diff --git a/src/onionrblocks/insert.py b/src/onionrblocks/insert.py index bf26ab4a..791bdc51 100644 --- a/src/onionrblocks/insert.py +++ b/src/onionrblocks/insert.py @@ -37,10 +37,11 @@ from onionrtypes import UserIDSecretKey def _check_upload_queue(): """Returns the current upload queue len - raises OverflowError if max + raises OverflowError if max, false if api not running """ max_upload_queue: int = 5000 queue = localcommand.local_command('/gethidden', maxWait=10) + up_queue = False try: 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 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 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)) 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 if type(data) is None: