Beispiel #1
0
def test_can_use_resource_with_template_uri():
    resource_tmpl = ResourceTemplate("http://localhost:8080/person/{name}")
    for name in PEOPLE.keys():
        with resource_tmpl.expand(name=name).get() as response:
            assert isinstance(response, JSONResponse)
            assert assembled(response) == PEOPLE[name]
Beispiel #2
0
def test_can_use_resource_with_template_uri():
    resource_tmpl = ResourceTemplate("http://localhost:8080/person/{name}")
    for name in PEOPLE.keys():
        with resource_tmpl.expand(name=name).get() as response:
            assert isinstance(response, JSONResponse)
            assert assembled(response) == PEOPLE[name]
Beispiel #3
0
def test_can_create_resource_template_from_empty_string():
    template = ResourceTemplate("")
    assert template.uri_template == URITemplate("")
    assert not bool(template)
    assert str(template) == "<>"
Beispiel #4
0
def test_can_create_none_resource_template():
    template = ResourceTemplate(None)
    assert template.uri_template == URITemplate(None)
    assert not bool(template)
    assert str(template) == "<>"
Beispiel #5
0
def test_can_get_substituted_uri():
    resource = ResourceTemplate("http://localhost:8080/person/{name}")
    rs = resource.expand(name="alice").get()
    assert rs.status_code == 200
Beispiel #6
0
def test_can_create_resource_template_from_uri_template():
    uri_template = URITemplate("http://example.com/foo/{bar}")
    template = ResourceTemplate(uri_template)
    assert template.uri_template == uri_template
    assert bool(template)
    assert str(template) == "<http://example.com/foo/{bar}>"
Beispiel #7
0
def test_can_create_resource_template_from_empty_uri_template():
    uri_template = URITemplate("")
    template = ResourceTemplate(uri_template)
    assert template.uri_template == uri_template
    assert not bool(template)
    assert str(template) == "<>"