コード例 #1
0
def test_construct_invalid_service_pattern():
    '''
    Should raise ValueError when pattern is missing
    '''

    endpoint = {"scheme": "scheme", "host": "host", "port": "port"}
    with pytest.raises(ValueError):
        common.construct_service_pattern(endpoint)
コード例 #2
0
def test_construct_invalid_service_pattern():
    '''
    Should raise ValueError when pattern is missing
    '''

    endpoint = {
        "scheme": "scheme",
        "host": "host",
        "port": "port"
    }
    with pytest.raises(ValueError):
        common.construct_service_pattern(endpoint)
コード例 #3
0
def test_construct_service_pattern():
    '''
    Should create a regex that can be used to dispatch operations
    '''

    endpoint = {
        "scheme": "scheme",
        "host": "host",
        "port": "port",
        "pattern": "/api/{operation}/suffix"
    }
    common.construct_service_pattern(endpoint)
    match = endpoint["service_pattern"].match("/api/foo/suffix")

    assert match
    assert match.groupdict()["operation"] == "foo"
コード例 #4
0
def test_construct_service_pattern():
    '''
    Should create a regex that can be used to dispatch operations
    '''

    endpoint = {
        "scheme": "scheme",
        "host": "host",
        "port": "port",
        "pattern": "/api/{operation}/suffix"
    }
    common.construct_service_pattern(endpoint)
    match = endpoint["service_pattern"].match("/api/foo/suffix")

    assert match
    assert match.groupdict()["operation"] == "foo"