import json import jsonschema DEFAULT_REQUEST_HEADERS = { "Content-type": "application/json", "Accept": ["application/json"] } ROUTER_LIST_SCHEMA = { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": {"type": "string"} } def test_flushdb(client): rv = client.post("/testing/flushdb") assert rv.status_code == 200 def test_infinera_addresses(client): rv = client.post( "/testing/infinera-dna-addresses", headers=DEFAULT_REQUEST_HEADERS) assert rv.status_code == 200 jsonschema.validate( json.loads(rv.data.decode("utf-8")), ROUTER_LIST_SCHEMA) def test_coriant_addresses(client): rv = client.post( "/testing/coriant-tnms-addresses", headers=DEFAULT_REQUEST_HEADERS) assert rv.status_code == 200 jsonschema.validate( json.loads(rv.data.decode("utf-8")), ROUTER_LIST_SCHEMA) def test_juniper_addresses(mocker, client): rv = client.post( "/testing/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, ROUTER_LIST_SCHEMA) assert len(response_data) > 0 # test data is not empty