예제 #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"