Exemplo n.º 1
0
def test_swaggerjmx_none_parameter():
    try:
        ST.swagger_json = None
        ST.swagger_url_json_path = None
        ST.swagger_url = None
        ST.report_path = 'jmx'
        # 开始转换
        conversion()
    except TypeError:
        assert True
def test_swaggerjmx_json_file():
    # swagger or yapi json path
    ST.swagger_json = None
    ST.swagger_url = None
    ST.swagger_url_json_path = os.path.join(
        str(__file__).replace("test_swaggerjmx_json_file.py", ""), 'data',
        'swagger.json')
    #  report_path
    ST.report_path = 'jmx'
    # 开始转换
    conversion()
    assert os.path.exists('./jmx/jmeter-Swagger-Petstore.jmx')
Exemplo n.º 3
0
def test_swaggerjmx_report_error():
    try:
        ST.swagger_json = None
        ST.swagger_url_json_path = os.path.join(
            str(__file__).replace("test_swaggerjmx_exceptions.py", ""), 'data',
            'swagger.json')
        ST.swagger_url = None
        ST.report_path = None
        # 开始转换
        conversion()
    except TypeError:
        assert True
def test_swaggerjmx_url():
    try:
        #  swagger_url
        ST.swagger_json = None
        ST.swagger_url_json_path = None
        ST.swagger_url = 'https://www.baidu.com'
        # 'https://ip:port/v2/api-docs'
        #  report_path
        ST.report_path = 'jmx'
        # 开始转换
        conversion()
    except SystemExit:
        assert os.path.exists('./jmx/jmeter-Swagger-Petstore.jmx')
def test_swaggerjmx_json():
    # swagger or yapi json
    with open(os.path.join(
            str(__file__).replace("test_swaggerjmx_json.py", ""), 'data',
            'swagger.json'),
              'r',
              encoding='utf-8') as f:
        data = json.load(f, strict=False)
    ST.swagger_json = data
    #  report_path
    ST.swagger_url_json_path = None
    ST.swagger_url = None
    ST.report_path = 'jmx'
    # 开始转换
    conversion()
    assert os.path.exists('./jmx/jmeter-Swagger-Petstore.jmx')
Exemplo n.º 6
0
def test_swaggerjmx_all_parameter():
    try:
        with open(os.path.join(
                str(__file__).replace("test_swaggerjmx_exceptions.py", ""),
                'data', 'swagger.json'),
                  'r',
                  encoding='utf-8') as f:
            data = json.load(f, strict=False)
        ST.swagger_json = data
        ST.swagger_url_json_path = os.path.join(
            str(__file__).replace("test_swaggerjmx_exceptions.py", ""), 'data',
            'swagger.json')
        ST.swagger_url = 'https://www.baidu.com/'
        ST.report_path = 'jmx'
        # 开始转换
        conversion()
    except TypeError:
        assert True
Exemplo n.º 7
0
def main():
    """Parse command line options and run commands.
    """
    parser = argparse.ArgumentParser(description=__description__)

    parser.add_argument(
        '-i', '--input', help='The input swagger json file or swagger url.', required=True)
    parser.add_argument(
        '-o', '--output', help='The output jmx file path(default jmx). If it exists, old file will be overwrite.',
        default="jmx")

    args = parser.parse_args()

    from swaggerjmx.settings import Settings as ST
    if str(args.input).startswith("http"):
        ST.swagger_url = args.input
    elif str(args.input).endswith(".json"):
        ST.swagger_url_json_path = args.input
    else:
        parser.print_help()
        sys.exit(0)
    #  report_path
    ST.report_path = args.output
    conversion()
Exemplo n.º 8
0
# -*- coding: utf-8 -*-
import os

from swaggerjmx.convert import conversion
from swaggerjmx.settings import Settings as ST

path = os.path.join(os.getcwd(), 'test.json')
ST.swagger_url_json_path = '/home/travis/build/Pactortester/swaggerjmx/tests/test.json'
ST.report_path = 'jmx'
conversion()