diff --git a/inventory_provider/data_routes.py b/inventory_provider/data_routes.py index 890c703034feecd04030fc1303ff7afc4abeadb0..804cbcebed9fc9f1fd819658a2f3033ab7afd698 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 c6bea77da2dd4859a54716946299ee25c6b9f999..7767eb76b5761eddd4bfa0b8587c38cf131ad6f6 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):