Skip to content
Snippets Groups Projects
Commit 3d69d5e5 authored by Erik Reid's avatar Erik Reid
Browse files

put mocking in a fixture

parent ec40c02a
No related branches found
No related tags found
No related merge requests found
......@@ -192,8 +192,18 @@ class MockedRedis(object):
def keys(self, *args, **kwargs):
return list([k.encode("utf-8") for k in MockedRedis.db.keys()])
@pytest.fixture
def client_with_mocked_data(mocker, client):
mocker.patch(
'inventory_provider.router_details.redis.StrictRedis',
MockedRedis)
mocker.patch(
'inventory_provider.routes.data.redis.StrictRedis',
MockedRedis)
return client
def test_routers_list(mocker, client):
def test_routers_list(client_with_mocked_data):
routers_list_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
......@@ -201,13 +211,7 @@ def test_routers_list(mocker, client):
"items": {"type": "string"}
}
mocker.patch(
'inventory_provider.router_details.redis.StrictRedis',
MockedRedis)
mocker.patch(
'inventory_provider.routes.data.redis.StrictRedis',
MockedRedis)
rv = client.post(
rv = client_with_mocked_data.post(
"data/routers",
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment