import json import jsonschema DEFAULT_REQUEST_HEADERS = { "Content-type": "application/json", "Accept": ["application/json"] } ACCESS_SERVICES_LIST_SCHEMA = { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "service": { "type": "object", "properties": { "id": {"type": "integer"}, "name": {"type": "string"}, "equipment": {"type": "string"}, "pop_name": {"type": "string"}, "other_end_equipment": {"type": "string"}, "other_end_pop_name": {"type": "string"}, "speed_value": {"type": "integer"}, "speed_unit": {"type": "string"} }, "required": [ "id", "name", "pop_name", "equipment", "other_end_pop_name", "other_end_equipment", "speed_value", "speed_unit" ], "additionalProperties": False } }, "type": "array", "items": {"$ref": "#/definitions/service"} } def test_access_services(client): rv = client.get( '/msr/access-services', headers=DEFAULT_REQUEST_HEADERS) assert rv.status_code == 200 assert rv.is_json response_data = json.loads(rv.data.decode('utf-8')) jsonschema.validate(response_data, ACCESS_SERVICES_LIST_SCHEMA) assert response_data # test data is non-empty