From c93ab2dbb1d3f8e015b521cdc9072861613230b9 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Thu, 4 Jun 2020 11:57:25 +0200
Subject: [PATCH] pep8

---
 inventory_provider/tasks/monitor.py |  7 ++++--
 test/test_job_routes.py             | 35 +++++++++++++++++------------
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/inventory_provider/tasks/monitor.py b/inventory_provider/tasks/monitor.py
index 389bf15a..a02ede72 100644
--- a/inventory_provider/tasks/monitor.py
+++ b/inventory_provider/tasks/monitor.py
@@ -10,9 +10,12 @@ import logging
 import os
 import queue
 import threading
+
+from redis.exceptions import RedisError
+
 from inventory_provider import config, environment
 from inventory_provider.tasks.worker import app
-from inventory_provider.tasks.common import get_current_redis, _get_redis
+from inventory_provider.tasks.common import _get_redis
 
 
 logger = logging.getLogger(__name__)
@@ -35,7 +38,7 @@ def _save_proc(db_queue, params, dbid):
     while True:
         try:
             _save_events(_get_redis(config=params, dbid=dbid), db_queue)
-        except:
+        except RedisError:
             logger.exception('redis i/o exception, reconnecting')
             # TODO: do something to terminate the process ...?
 
diff --git a/test/test_job_routes.py b/test/test_job_routes.py
index b563ca13..b7ff1ddf 100644
--- a/test/test_job_routes.py
+++ b/test/test_job_routes.py
@@ -256,22 +256,29 @@ def test_latchdb(client, mocked_redis):
     jsonschema.validate(latch, DB_LATCH_SCHEMA)
 
 
-
-TEST_EVENTS = {
-    'joblog:AAAA:task-aaa': {'type': 'task-aaaa', 'uuid': 'AAAA', 'clock': 999},
-    'joblog:AAAB:task-infox': {'type': 'task-infox', 'uuid': 'AAAB', 'clock': 999},
-    'joblog:BBBB:task-info:99': {'type': 'task-info', 'uuid': 'BBBB', 'clock': 99},
-    'joblog:BBBB:task-info:999': {'type': 'task-info', 'uuid': 'BBBB', 'clock': 999},
-    'joblog:AAAA:task-warning:88': {'type': 'task-warning', 'uuid': 'AAAA', 'clock': 88},
-    'joblog:AAAA:task-warning:888': {'type': 'task-warning', 'uuid': 'AAAA', 'clock': 888},
-    'joblog:AAAA:task-error:77': {'type': 'task-error', 'uuid': 'AAAA', 'clock': 77},
-    'joblog:AAAA:task-error:777': {'type': 'task-error', 'uuid': 'AAAA', 'clock': 777}
-}
-
 def test_job_log(client):
 
+    test_events = {
+        'joblog:AAAA:task-aaa': {
+            'type': 'task-aaaa', 'uuid': 'AAAA', 'clock': 999},
+        'joblog:AAAB:task-infox': {
+            'type': 'task-infox', 'uuid': 'AAAB', 'clock': 999},
+        'joblog:BBBB:task-info:99': {
+            'type': 'task-info', 'uuid': 'BBBB', 'clock': 99},
+        'joblog:BBBB:task-info:999': {
+            'type': 'task-info', 'uuid': 'BBBB', 'clock': 999},
+        'joblog:AAAA:task-warning:88': {
+            'type': 'task-warning', 'uuid': 'AAAA', 'clock': 88},
+        'joblog:AAAA:task-warning:888': {
+            'type': 'task-warning', 'uuid': 'AAAA', 'clock': 888},
+        'joblog:AAAA:task-error:77': {
+            'type': 'task-error', 'uuid': 'AAAA', 'clock': 77},
+        'joblog:AAAA:task-error:777': {
+            'type': 'task-error', 'uuid': 'AAAA', 'clock': 777}
+    }
+
     db = backend_db()
-    for k, v in TEST_EVENTS.items():
+    for k, v in test_events.items():
         db[k] = json.dumps(v)
 
     rv = client.post(
@@ -279,4 +286,4 @@ def test_job_log(client):
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
-    assert len(result.keys()) == 3  # TODO: make a proper test
\ No newline at end of file
+    assert len(result.keys()) == 3  # TODO: make a proper test
-- 
GitLab