From aafef5e03323e15b7a91b146383a749f125a9e02 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Wed, 14 Nov 2018 12:58:30 +0100
Subject: [PATCH] use saved test data for tests

---
 inventory_provider/data_routes.py |  2 +-
 test/test_data_routes.py          | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/inventory_provider/data_routes.py b/inventory_provider/data_routes.py
index 890c7030..804cbceb 100644
--- a/inventory_provider/data_routes.py
+++ b/inventory_provider/data_routes.py
@@ -49,5 +49,5 @@ def abc():
         host=redis_config["hostname"],
         port=redis_config["port"])
     return Response(
-        json.dumps(r.keys("*")),
+        json.dumps(list(r.keys("*"))),
         mimetype="application/json")
diff --git a/test/test_data_routes.py b/test/test_data_routes.py
index c6bea77d..7767eb76 100644
--- a/test/test_data_routes.py
+++ b/test/test_data_routes.py
@@ -166,18 +166,25 @@ def test_version_request(client):
         version_schema)
 
 
+TEST_DATA_FILENAME = os.path.join(
+    os.path.dirname(__file__),
+    "router-info.json")
+
+
 class MockedRedis(object):
 
-    db = {}
+    db = None
 
     def __init__(self, *args, **kwargs):
-        pass
+        if MockedRedis.db is None:
+            with open(TEST_DATA_FILENAME) as f:
+                MockedRedis.db = json.loads(f.read())
 
     def set(self, key, value):
         MockedRedis.db[key] = value
 
     def keys(self, *args, **kwargs):
-        return ["a", "b", "c"]
+        return MockedRedis.db.keys()
 
 
 def test_abc(mocker, client):
-- 
GitLab