From 4e6b64daf59a3674847b1fd111ca78bd34df2dc2 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Sun, 3 Feb 2019 21:07:33 +0100
Subject: [PATCH] pep8

---
 inventory_provider/juniper.py           |  2 ++
 inventory_provider/routes/classifier.py |  3 --
 inventory_provider/routes/default.py    |  1 -
 inventory_provider/routes/opsdb.py      |  2 +-
 inventory_provider/tasks/common.py      |  1 -
 inventory_provider/tasks/worker.py      |  6 ++--
 test/conftest.py                        |  3 +-
 test/test_external_inventory_routes.py  | 38 ++-----------------------
 8 files changed, 10 insertions(+), 46 deletions(-)

diff --git a/inventory_provider/juniper.py b/inventory_provider/juniper.py
index ebb015dd..7645ed5a 100644
--- a/inventory_provider/juniper.py
+++ b/inventory_provider/juniper.py
@@ -112,6 +112,7 @@ def _rpc(hostname, ssh):
 
 def validate_netconf_config(config_doc):
     juniper_logger = logging.getLogger(JUNIPER_LOGGER_NAME)
+
     def _validate(schema, doc):
         if schema.validate(doc):
             return
@@ -131,6 +132,7 @@ def validate_netconf_config(config_doc):
         for u in i.xpath('./unit'):
             _validate(unit_schema, u)
 
+
 def load_config(hostname, ssh_params):
     """
     loads netconf data from the router, validates and
diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py
index 4d5f896a..62124e16 100644
--- a/inventory_provider/routes/classifier.py
+++ b/inventory_provider/routes/classifier.py
@@ -1,7 +1,6 @@
 import json
 
 from flask import Blueprint, Response, current_app, jsonify
-import jsonschema
 
 from inventory_provider.routes import common
 
@@ -38,8 +37,6 @@ def juniper_addresses():
               methods=['GET', 'POST'])
 @common.require_accepts_json
 def get_trap_metadata(source_equipment, interface):
-    # todo - Move this to config
-    interface_info_key = "interface_services"
     r = common.get_redis()
 
     # todo - Change this to a call to the yet-to-be-created one source of all
diff --git a/inventory_provider/routes/default.py b/inventory_provider/routes/default.py
index 38bf3ea3..fd480bac 100644
--- a/inventory_provider/routes/default.py
+++ b/inventory_provider/routes/default.py
@@ -1,4 +1,3 @@
-import json
 import pkg_resources
 
 from flask import Blueprint, jsonify
diff --git a/inventory_provider/routes/opsdb.py b/inventory_provider/routes/opsdb.py
index 8543c25d..4b7fba38 100644
--- a/inventory_provider/routes/opsdb.py
+++ b/inventory_provider/routes/opsdb.py
@@ -2,7 +2,7 @@ import collections
 import json
 import re
 
-from flask import Blueprint, Response, jsonify
+from flask import Blueprint, jsonify
 from inventory_provider.routes import common
 
 routes = Blueprint("inventory-opsdb-query-routes", __name__)
diff --git a/inventory_provider/tasks/common.py b/inventory_provider/tasks/common.py
index 6868ffa3..34240835 100644
--- a/inventory_provider/tasks/common.py
+++ b/inventory_provider/tasks/common.py
@@ -5,4 +5,3 @@ def get_redis(config):
     return redis.StrictRedis(
         host=config['redis']['hostname'],
         port=config['redis']['port'])
-
diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py
index 8b9ebd6d..54c26e58 100644
--- a/inventory_provider/tasks/worker.py
+++ b/inventory_provider/tasks/worker.py
@@ -16,10 +16,10 @@ from inventory_provider.db import db, opsdb, alarmsdb
 from inventory_provider import snmp
 from inventory_provider import juniper
 
+# TODO: error callback (cf. http://docs.celeryproject.org/en/latest/userguide/calling.html#linking-callbacks-errbacks)  # noqa: E501
 
 environment.setup_logging()
 
-# TODO: error callback (cf. http://docs.celeryproject.org/en/latest/userguide/calling.html#linking-callbacks-errbacks)
 
 class InventoryTask(Task):
 
@@ -201,12 +201,12 @@ def update_circuit_hierarchy():
 @app.task()
 def update_interface_statuses():
     with db.connection(InventoryTask.config["ops-db"]) as cx:
-            services = opsdb.get_circuits(cx)
+        services = opsdb.get_circuits(cx)
     with db.connection(InventoryTask.config["alarms-db"]) as cx:
         with db.cursor(cx) as csr:
             for service in services:
                 key = 'alarmsdb:interface_status:%s:%s' \
-                    % (service['equipment'], service['interface_name'])
+                      % (service['equipment'], service['interface_name'])
                 status = alarmsdb.get_last_known_interface_status(
                     csr,
                     service["equipment"],
diff --git a/test/conftest.py b/test/conftest.py
index d48a042a..52fa1af3 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -85,6 +85,7 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
     "test",
     "data"))
 
+
 class MockedRedis(object):
 
     db = None
@@ -109,7 +110,7 @@ class MockedRedis(object):
     def keys(self, glob=None):
         if not glob:
             return list([k.encode("utf-8") for k in MockedRedis.db.keys()])
-        m = re.match('^([^\*]+)\*$', glob)
+        m = re.match(r'^([^*]+)\*$', glob)
         assert m  # all expected global are like this
         return list([
             k.encode("utf-8") for k in MockedRedis.db.keys()
diff --git a/test/test_external_inventory_routes.py b/test/test_external_inventory_routes.py
index 5087bac3..ba7d6149 100644
--- a/test/test_external_inventory_routes.py
+++ b/test/test_external_inventory_routes.py
@@ -1,8 +1,3 @@
-import json
-import os
-
-import inventory_provider
-from inventory_provider.tasks import worker
 
 DEFAULT_REQUEST_HEADERS = {
     "Content-type": "application/json",
@@ -10,36 +5,6 @@ DEFAULT_REQUEST_HEADERS = {
 }
 
 
-
-# def test_get_one_equipment_location(mocker, client):
-#     mocked_redis = mocker.patch(
-#         "inventory_provider.routes.common.get_redis")
-#     mocked_hget = mocked_redis.return_value.hget
-#     dummy_data = {
-#         "absid": 1404,
-#         "equipment_name": "pp-cz-e13b",
-#         "pop_name": "Prague",
-#         "pop_abbreviation": "pra",
-#         "pop_site_id": "",
-#         "country": "Czech Republic",
-#         "longitude": 14.391738888889,
-#         "latitude": 50.101847222222
-#     }
-#     mocked_hget.return_value = json.dumps(dummy_data)
-#
-#     rv = client.get(
-#         '/opsdb/equipment-location/dummy-equipment',
-#         headers=DEFAULT_REQUEST_HEADERS)
-#     assert rv.status_code == 200
-#     assert rv.is_json
-#     assert dummy_data == json.loads(rv.data.decode("utf-8"))
-#
-#     mocked_hget.assert_called_with(
-#         worker.equipment_locations_key,
-#         "dummy-equipment"
-#     )
-
-
 def test_get_equipment_location(client_with_mocked_data):
     rv = client_with_mocked_data.get(
         '/opsdb/equipment-location',
@@ -67,7 +32,8 @@ def test_get_interface_info_for_equipment(client_with_mocked_data):
     # TODO: validate against schema
 
 
-def test_get_interface_info_for_equipment_and_interface(client_with_mocked_data):
+def test_get_interface_info_for_equipment_and_interface(
+        client_with_mocked_data):
     rv = client_with_mocked_data.get(
         '/opsdb/interfaces/mx1.ams.nl.geant.net/ae0.0',
         headers=DEFAULT_REQUEST_HEADERS)
-- 
GitLab