Skip to content
Snippets Groups Projects
test_routes.py 1.05 KiB
import json
import jsonschema

DEFAULT_REQUEST_HEADERS = {
    'Content-type': 'application/json',
    'Accept': ['application/json']
}


def test_version_request(client):

    version_schema = {
        '$schema': 'http://json-schema.org/draft-07/schema#',

        'type': 'object',
        'properties': {
            'api': {
                'type': 'string',
                'pattern': r'\d+\.\d+'
            },
            'module': {
                'type': 'string',
                'pattern': r'\d+\.\d+'
            }
        },
        'required': ['api', 'module'],
        'additionalProperties': False
    }

    rv = client.post(
        'version',
        headers=DEFAULT_REQUEST_HEADERS)
    assert rv.status_code == 200
    jsonschema.validate(
        json.loads(rv.data.decode('utf-8')),
        version_schema)


def test_test_proc1(client):

    rv = client.post(
        'test/test1',
        headers=DEFAULT_REQUEST_HEADERS)
    assert rv.status_code == 200
    result = json.loads(rv.data.decode('utf-8'))
    assert result  # boilerplate test ...