Esempio n. 1
0
def check_endpoint(endpoint):
    try:
        return client.parse_endpoint(endpoint)
    except client.InvalidProtocol as e:
        raise argparse.ArgumentTypeError(str(e))
    except client.InvalidHost as e:
        raise argparse.ArgumentTypeError(str(e))
Esempio n. 2
0
def check_endpoint(endpoint):
    try:
        return client.parse_endpoint(endpoint)
    except InvalidProtocol as e:
        raise argparse.ArgumentTypeError(str(e))
    except client.InvalidHost as e:
        raise argparse.ArgumentTypeError(str(e))
Esempio n. 3
0
def _test_configure_endpoints(dest_url, dest_region, dest_zone,
                              expected_src_url, expected_src_region,
                              expected_src_zone, specified_src_url=None,
                              meta_only=False):
    dest = client.parse_endpoint(dest_url)
    if specified_src_url is not None:
        src = client.parse_endpoint(specified_src_url)
    else:
        src = client.Endpoint(None, None, None)
    region_map = client.RegionMap(REGION_MAP)
    client.configure_endpoints(region_map, dest, src, meta_only)
    assert dest.region.name == dest_region
    assert dest.zone.name == dest_zone
    assert src == client.parse_endpoint(expected_src_url)
    assert src.region.name == expected_src_region
    assert src.zone.name == expected_src_zone
Esempio n. 4
0
def _test_configure_endpoints(dest_url, dest_region, dest_zone,
                              expected_src_url, expected_src_region,
                              expected_src_zone, specified_src_url=None,
                              meta_only=False):
    dest = client.parse_endpoint(dest_url)
    if specified_src_url is not None:
        src = client.parse_endpoint(specified_src_url)
    else:
        src = client.Endpoint(None, None, None)
    region_map = client.RegionMap(REGION_MAP)
    client.configure_endpoints(region_map, dest, src, meta_only)
    assert dest.region.name == dest_region
    assert dest.zone.name == dest_zone
    assert src == client.parse_endpoint(expected_src_url)
    assert src.region.name == expected_src_region
    assert src.zone.name == expected_src_zone
Esempio n. 5
0
def test_parse_endpoint():
    endpoints = {
        'http://example.org': ('example.org', 80, False),
        'https://example.org': ('example.org', 443, True),
        'https://example.org:8080': ('example.org', 8080, True),
        'https://example.org:8080/': ('example.org', 8080, True),
        'http://example.org:81/a/b/c?b#d': ('example.org', 81, False),
        }
    for url, (host, port, secure) in endpoints.iteritems():
        endpoint = client.parse_endpoint(url)
        assert endpoint.port == port
        assert endpoint.host == host
        assert endpoint.secure == secure
Esempio n. 6
0
def test_parse_endpoint_bad_input():
    with py.test.raises(client.InvalidProtocol):
        client.parse_endpoint('ftp://example.com')
    with py.test.raises(client.InvalidHost):
        client.parse_endpoint('http://:80/')
Esempio n. 7
0
def test_parse_repr(url, host, port, secure):
    endpoint = repr(client.parse_endpoint(url))
    assert str(secure) in endpoint
    assert str(host) in endpoint
    assert str(port) in endpoint
Esempio n. 8
0
def test_parse_endpoint(url, host, port, secure):
    endpoint = client.parse_endpoint(url)
    assert endpoint.port == port
    assert endpoint.host == host
    assert endpoint.secure == secure
Esempio n. 9
0
def test_parse_endpoint_bad_input():
    with py.test.raises(exc.InvalidProtocol):
        client.parse_endpoint('ftp://example.com')
    with py.test.raises(exc.InvalidHost):
        client.parse_endpoint('http://:80/')
Esempio n. 10
0
def test_parse_repr(url, host, port, secure):
    endpoint = repr(client.parse_endpoint(url))
    assert str(secure) in endpoint
    assert str(host) in endpoint
    assert str(port) in endpoint
Esempio n. 11
0
def test_parse_endpoint(url, host, port, secure):
    endpoint = client.parse_endpoint(url)
    assert endpoint.port == port
    assert endpoint.host == host
    assert endpoint.secure == secure