コード例 #1
0
def test_no_overrides(origin_url):
    spec = {}
    assert origin_url == build_api_serving_url(spec, origin_url)
コード例 #2
0
def test_use_spec_url_False_when_basePath_and_origin_url_present(origin_url):
    api_serving_url = build_api_serving_url(
        {'basePath': '/v1'}, origin_url,
        use_spec_url_for_base_path=True,
    )
    assert 'http://www.foo.com:80/v1' == api_serving_url
コード例 #3
0
def test_override_scheme_multiple_schemes(origin_url):
    spec = {'schemes': ['https', 'ws']}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'https://www.foo.com:80/' == api_serving_url
コード例 #4
0
def test_override_scheme(origin_url):
    spec = {'schemes': ['https']}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'https://www.foo.com:80/bar/api-docs' == api_serving_url
コード例 #5
0
def test_use_spec_url_False_when_origin_url_present(origin_url):
    api_serving_url = build_api_serving_url(
        {}, origin_url,
        use_spec_url_for_base_path=False,
    )
    assert 'http://www.foo.com:80/' == api_serving_url
コード例 #6
0
def test_override_scheme(origin_url):
    spec = {'schemes': ['https']}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'https://www.foo.com:80/bar/api-docs' == api_serving_url
コード例 #7
0
def test_preferred_scheme_not_available(origin_url):
    spec = {'schemes': ['https']}
    with pytest.raises(Exception) as excinfo:
        build_api_serving_url(spec, origin_url, preferred_scheme='ws')
    assert 'not supported' in str(excinfo.value)
コード例 #8
0
def test_override_host(origin_url):
    spec = {'host': 'womble.com'}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://womble.com/' == api_serving_url
コード例 #9
0
def test_override_basepath(origin_url):
    spec = {'basePath': '/v1'}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://www.foo.com:80/v1' == api_serving_url
コード例 #10
0
def test_no_overrides(origin_url):
    spec = {}
    assert 'http://www.foo.com:80/' == build_api_serving_url(spec, origin_url)
コード例 #11
0
def test_origin_url_None():
    assert 'http://localhost/' == build_api_serving_url({})
コード例 #12
0
def test_preferred_scheme_not_available(origin_url):
    spec = {'schemes': ['https']}
    with pytest.raises(SwaggerSchemaError) as excinfo:
        build_api_serving_url(spec, origin_url, preferred_scheme='ws')
    assert 'not supported' in str(excinfo.value)
コード例 #13
0
def test_pick_origin_scheme_when_preferred_scheme_none(origin_url):
    spec = {'schemes': ['http', 'https']}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://www.foo.com:80/' == api_serving_url
コード例 #14
0
def test_pick_preferred_scheme(origin_url):
    spec = {'schemes': ['http', 'https']}
    api_serving_url = build_api_serving_url(
        spec, origin_url, preferred_scheme='https',
    )
    assert 'https://www.foo.com:80/' == api_serving_url
コード例 #15
0
def test_override_host(origin_url):
    spec = {'host': 'womble.com'}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://womble.com/bar/api-docs' == api_serving_url
コード例 #16
0
def test_use_spec_url_True_when_origin_url_present(origin_url):
    api_serving_url = build_api_serving_url(
        {}, origin_url,
        use_spec_url_for_base_path=True,
    )
    assert 'http://www.foo.com:80/bar/api-docs' == api_serving_url
コード例 #17
0
def test_override_basepath(origin_url):
    spec = {'basePath': '/v1'}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://www.foo.com:80/v1' == api_serving_url
コード例 #18
0
def test_use_spec_url_False():
    api_serving_url = build_api_serving_url(
        {},
        use_spec_url_for_base_path=False,
    )
    assert 'http://localhost/' == api_serving_url
コード例 #19
0
def test_pick_origin_scheme_when_preferred_scheme_none(origin_url):
    spec = {'schemes': ['http', 'https']}
    api_serving_url = build_api_serving_url(spec, origin_url)
    assert 'http://www.foo.com:80/bar/api-docs' == api_serving_url
コード例 #20
0
def test_use_spec_url_False_when_basePath_present():
    api_serving_url = build_api_serving_url(
        {'basePath': '/v1'},
        use_spec_url_for_base_path=False,
    )
    assert 'http://localhost/v1' == api_serving_url
コード例 #21
0
def test_origin_url_None():
    assert 'http://localhost/' == build_api_serving_url({})
コード例 #22
0
def test_no_overrides(origin_url):
    spec = {}
    assert origin_url == build_api_serving_url(spec, origin_url)