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

added '/classifier/juniper-server-addresses' unit test

parent aff4fd6a
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ DEFAULT_REQUEST_HEADERS = {
}
def test_version_request(client):
def test_infinera_addresses(client):
response_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
......@@ -22,3 +22,39 @@ def test_version_request(client):
json.loads(rv.data.decode("utf-8")),
response_schema)
def test_juniper_addresses(mocker, client):
test_data = [
{"ip_address": "a.b.c.d", "project_name": "AAABBB"},
{"ip_address": "b.c.d.e", "project_name": "CCCCDDDDD"},
{"ip_address": "c.d.e.f", "project_name": "EFEFEFEF"},
{"ip_address": "::1", "project_name": "GGHHGGHH"}
]
class MockedRedis():
def __init__(self):
pass
def get(self, ignored):
return json.dumps(test_data).encode('utf-8')
mocker.patch(
'inventory_provider.routes.classifier.db.get_redis',
return_value=MockedRedis())
response_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {"type": "string"}
}
rv = client.post(
"/classifier/juniper-server-addresses",
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, response_schema)
assert len(response_data) == len(test_data)
assert set([x['ip_address'] for x in test_data]) == set(response_data)
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