Ejemplo n.º 1
0
def test_swagger_test_specify_app_url_dont_use_example():
    conn = ConnexionProcess()
    conn.start()
    swagger_test(app_url=swagger_io_url,
                 authorize_error=authorize_error,
                 use_example=False)
    conn.terminate()
def test_swagger_test_app_url(example):
    port = get_open_port()
    swagger_yaml_path = os.path.join(os.path.dirname(__file__), 'swagger.yaml')

    app = connexion.App(__name__, port=port, specification_dir=os.path.dirname(os.path.realpath(swagger_yaml_path)))
    app.add_api(os.path.basename(swagger_yaml_path))
    server = threading.Thread(None, app.run)
    server.daemon = True
    server.start()

    time.sleep(3)  # Make sure the server has started

    swagger_test(app_url='http://localhost:{0}/v2'.format(port), use_example=example)
def test_swagger_test_app_url():
    authorize_error = {
        'post': {
            '/pet/{petId}': [200],
            '/pet': [200]
        },
        'put': {
            '/user/{username}': [200],
            '/pet': [200]
        },
        'delete': {
            '/pet/{petId}': [200],
            '/store/order/{orderId}': [200],
            '/user/{username}': [200]
        }
    }

    swagger_test(app_url='http://petstore.swagger.io/v2',
                 authorize_error=authorize_error)
def test_swagger_test(example):
    swagger_test(os.path.join(os.path.dirname(__file__), 'swagger.yaml'), use_example=example)
Ejemplo n.º 5
0
from swagger_tester import swagger_test

swagger_test(app_url='http://localhost:8080')
Ejemplo n.º 6
0
#!/usr/bin/env python

import os

from swagger_tester import swagger_test

WEB_SERVER_HOST = os.getenv('WEB_SERVER_HOST', 'localhost')
WEB_SERVER_PORT = os.getenv('WEB_SERVER_PORT', '5000')
URL = 'http://{0}:{1}/api/v1'.format(WEB_SERVER_HOST, WEB_SERVER_PORT)

authorize_error = {
    'get': {
        '/api/v1/artifact/{artifact_id}': [404, 200],
        '/api/v1/promote/{promote_id}': [404, 200],
        '/api/v1/build/{build_id}': [404, 200],
        '/api/v1/deploy/{deploy_id}': [404, 200],
    },
    'post': {
        '/api/v1/artifact': [404, 200],
        '/api/v1/promote': [404, 200],
        '/api/v1/environment/current': [409, 200],
    },
}

swagger_test(app_url=URL, authorize_error=authorize_error)
Ejemplo n.º 7
0
from swagger_tester import swagger_test

# Dict containing the error you don't want to raise.
# By default, every status_code over other than 1xx, 2xx or 3xx
# will be considered as an error.
authorize_error = {
    'get': {
        '/broker/info': [200],
        '/messages/all': [200],
        '/messages/all/{time}': [200],
        '/messages/on_topic': [200],
        '/messages/on_topic/starting_from': [200],
        '/topics/list': [200]
    },
    'delete': {
        '/topics/remove/{topic}': [200],
        '/topics/remove/{topic}': [400]
    }
}


# Run the test with connexion
# An AssertionError will be raise in case of error.
swagger_test(app_url="http://localhost:12344", authorize_error=authorize_error)
def test_swagger():
    swagger_test('swagger.yml',
                 authorize_error=authorize_error,
                 use_example=True)
Ejemplo n.º 9
0
def test_swagger_test_dont_use_example():
    swagger_test(swagger_yaml_path, use_example=False)
Ejemplo n.º 10
0
def test_swagger_test_use_example():
    swagger_test(swagger_yaml_path, use_example=True)
Ejemplo n.º 11
0
def test_swagger_test(example):
    swagger_test(os.path.join(os.path.dirname(__file__), 'swagger.yaml'),
                 use_example=example)
Ejemplo n.º 12
0
from swagger_tester import swagger_test

# Dict containing the error you don't want to raise.
# By default, every status_code over other than 1xx, 2xx or 3xx
# will be considered as an error.
authorize_error = {
    'get': {
        '/artifact/{storage_backend}/{bucket_name}/{artifact_name}': [200]
    }
}

# Run the test with connexion
# An AssertionError will be raise in case of error.
swagger_test('/app/storage_proxy/swagger.yaml', authorize_error=authorize_error)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb  6 11:51:01 2018

@author: philld
"""
from swagger_tester import swagger_test

swagger_test('/home/philld/api/swagger_monkey.yaml')