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

added a test of coriant route, but that mocks all sql access

parent 2b9f1052
Branches
Tags
No related merge requests found
......@@ -271,3 +271,35 @@ def test_peer_not_found(client_with_mocked_data):
'/classifier/peer-info/1.2.3.4',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 404
import contextlib
def test_coriant_info(client, mocker):
"""
just check the correct method is called, but mock out all sql access
"""
expected_response = {
'C': 'bogus connection',
'E': 'bogus equipment name',
'CID': 'bogus card id',
'P': 'bogus card number'
}
@contextlib.contextmanager
def mocked_connection(ignored):
yield expected_response['C']
mocker.patch(
'inventory_provider.db.db.connection', mocked_connection)
mocker.patch(
'inventory_provider.db.opsdb.get_coriant_path',
lambda a, b, c, d: {'C': a, 'E': b, 'CID': c, 'P': d})
rv = client.get(
'/classifier/coriant-info/{E}/{CID}/{P}'.format(**expected_response),
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
assert response_data == expected_response
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment