Exemplo n.º 1
0
def test_form_style_query():
    assert rfc.expand_segments("{?x,y}", [x, y]) == "{?x,y}"
    assert rfc.expand_pairs("{?x,y}", [("x", x), ("y", y)]) == "?x=1024&y=768"
    assert rfc.expand_pairs("{?x,y,empty}",
                            [("x", x),
                             ("y", y),
                             ("empty", empty)]) == "?x=1024&y=768&empty="
Exemplo n.º 2
0
def test_form_style_query_continuation():
    assert rfc.expand_segments("{&x,y}", [x, y]) == "{&x,y}"
    assert rfc.expand_pairs("?fixed=yes{&x}",
                            [("x", x)]) == "?fixed=yes&x=1024"
    assert rfc.expand_pairs("{&x,y,empty}",
                            [("x", x), ("y", y),
                             ("empty", empty)]) == "&x=1024&y=768&empty="
Exemplo n.º 3
0
def test_path_style_parameters():
    assert rfc.expand_segments("{;x,y}", [x, y]) == "{;x,y}"
    assert rfc.expand_pairs("{;x,y}", [("x", x), ("y", y)]) == ";x=1024;y=768"
    assert rfc.expand_pairs("{;x,y,empty}",
                            [("x", x),
                             ("y", y),
                             ("empty", empty)]) == ";x=1024;y=768;empty"
Exemplo n.º 4
0
def test_form_style_query_continuation():
    assert rfc.expand_segments("{&x,y}", [x, y]) == "{&x,y}"
    assert rfc.expand_pairs("?fixed=yes{&x}",
                            [("x", x)]) == "?fixed=yes&x=1024"
    assert rfc.expand_pairs("{&x,y,empty}",
                            [("x", x),
                             ("y", y),
                             ("empty", empty)]) == "&x=1024&y=768&empty="
Exemplo n.º 5
0
def test_partial_segments():
    assert rfc.expand_segments("{var}", []) == ""
    assert rfc.expand_segments("{var}", [], partial=True) == "{var}"
    assert rfc.expand_segments("{+path}/{var}", [path], partial=True) == "/foo/bar/{var}"
    assert rfc.expand_segments("{x,y}", [x], partial=True) == "1024{y}"
    assert rfc.expand_segments("{/var,x}", [var], partial=True) == "/value{/x}"
    assert rfc.expand_segments("{/var,x,empty}", [var], partial=True) == "/value{/x,empty}"
Exemplo n.º 6
0
def test_partial_segments():
    assert rfc.expand_segments("{var}", []) == ""
    assert rfc.expand_segments("{var}", [], partial=True) == "{var}"
    assert rfc.expand_segments("{+path}/{var}", [path],
                               partial=True) == "/foo/bar/{var}"
    assert rfc.expand_segments("{x,y}", [x], partial=True) == "1024{y}"
    assert rfc.expand_segments("{/var,x}", [var], partial=True) == "/value{/x}"
    assert rfc.expand_segments("{/var,x,empty}", [var],
                               partial=True) == "/value{/x,empty}"
Exemplo n.º 7
0
def test_label_expansion():
    assert rfc.expand_segments("X{.var}", [var]) == "X.value"
    assert rfc.expand_segments("X{.x,y}", [x, y]) == "X.1024,768"
Exemplo n.º 8
0
def test_reserved_expansion_with_multiple_variables():
    assert rfc.expand_segments("{+x,hello,y}", [x, hello, y]) == "1024,Hello%20World!,768"
    assert rfc.expand_segments("{+path,x}/here", [path, x]) == "/foo/bar,1024/here"
Exemplo n.º 9
0
def test_fragment_expansion():
    assert rfc.expand_segments("X{#var}", [var]) == "X#value"
    assert rfc.expand_segments("X{#hello}", [hello]) == "X#Hello%20World!"
Exemplo n.º 10
0
def test_reserved_expansion_with_multiple_variables():
    assert rfc.expand_segments("{+x,hello,y}",
                               [x, hello, y]) == "1024,Hello%20World!,768"
    assert rfc.expand_segments("{+path,x}/here",
                               [path, x]) == "/foo/bar,1024/here"
Exemplo n.º 11
0
def test_string_expansion_with_multiple_variables():
    assert rfc.expand_segments("map?{x,y}", [x, y]) == "map?1024,768"
    assert rfc.expand_segments("{x,hello,y}",
                               [x, hello, y]) == "1024,Hello%20World%21,768"
Exemplo n.º 12
0
def test_fragment_expansion():
    assert rfc.expand_segments("X{#var}", [var]) == "X#value"
    assert rfc.expand_segments("X{#hello}", [hello]) == "X#Hello%20World!"
Exemplo n.º 13
0
def test_reserved_string_expansion():
    assert rfc.expand_segments("{+var}", [var]) == "value"
    assert rfc.expand_segments("{+hello}", [hello]) == "Hello%20World!"
    assert rfc.expand_segments("{+path}/here", [path]) == "/foo/bar/here"
    assert rfc.expand_segments("here?ref={+path}",
                               [path]) == "here?ref=/foo/bar"
Exemplo n.º 14
0
def test_combined():
    subject = rfc.expand_segments("http://example.com/{var}{+path}{?x,y}",
                                  [var, path])
    expected = "http://example.com/value/foo/bar?x=1024&y=768"

    assert rfc.expand_pairs(subject, [("x", x), ("y", y)]) == expected
Exemplo n.º 15
0
def test_simple_string_expansion():
    assert rfc.expand_segments("{var}", [var]) == "value"
    assert rfc.expand_segments("{hello}", [hello]) == "Hello%20World%21"
Exemplo n.º 16
0
def test_simple_string_expansion():
    assert rfc.expand_segments("{var}", [var]) == "value"
    assert rfc.expand_segments("{hello}", [hello]) == "Hello%20World%21"
Exemplo n.º 17
0
def test_reserved_string_expansion():
    assert rfc.expand_segments("{+var}", [var]) == "value"
    assert rfc.expand_segments("{+hello}", [hello]) == "Hello%20World!"
    assert rfc.expand_segments("{+path}/here", [path]) == "/foo/bar/here"
    assert rfc.expand_segments("here?ref={+path}", [path]) == "here?ref=/foo/bar"
Exemplo n.º 18
0
def test_fragment_expansion_with_multiple_variables():
    assert rfc.expand_segments("{#x,hello,y}",
                               [x, hello, y]) == "#1024,Hello%20World!,768"
    assert rfc.expand_segments("{#path,x}/here",
                               [path, x]) == "#/foo/bar,1024/here"
Exemplo n.º 19
0
def test_string_expansion_with_multiple_variables():
    assert rfc.expand_segments("map?{x,y}", [x, y]) == "map?1024,768"
    assert rfc.expand_segments("{x,hello,y}", [x, hello, y]) == "1024,Hello%20World%21,768"
Exemplo n.º 20
0
def test_label_expansion():
    assert rfc.expand_segments("X{.var}", [var]) == "X.value"
    assert rfc.expand_segments("X{.x,y}", [x, y]) == "X.1024,768"
Exemplo n.º 21
0
def test_fragment_expansion_with_multiple_variables():
    assert rfc.expand_segments("{#x,hello,y}", [x, hello, y]) == "#1024,Hello%20World!,768"
    assert rfc.expand_segments("{#path,x}/here", [path, x]) == "#/foo/bar,1024/here"
Exemplo n.º 22
0
def test_path_segments():
    assert rfc.expand_segments("{/var}", [var]) == "/value"
    assert rfc.expand_segments("{/var,x}/here", [var, x]) == "/value/1024/here"
Exemplo n.º 23
0
def test_path_segments():
    assert rfc.expand_segments("{/var}", [var]) == "/value"
    assert rfc.expand_segments("{/var,x}/here", [var, x]) == "/value/1024/here"
Exemplo n.º 24
0
def test_path_style_parameters():
    assert rfc.expand_segments("{;x,y}", [x, y]) == "{;x,y}"
    assert rfc.expand_pairs("{;x,y}", [("x", x), ("y", y)]) == ";x=1024;y=768"
    assert rfc.expand_pairs("{;x,y,empty}",
                            [("x", x), ("y", y),
                             ("empty", empty)]) == ";x=1024;y=768;empty"
Exemplo n.º 25
0
def test_combined():
    assert rfc.expand_pairs(rfc.expand_segments("http://example.com/{var}{+path}{?x,y}", [var, path]),
                            [("x", x), ("y", y)]) == "http://example.com/value/foo/bar?x=1024&y=768"
Exemplo n.º 26
0
def test_form_style_query():
    assert rfc.expand_segments("{?x,y}", [x, y]) == "{?x,y}"
    assert rfc.expand_pairs("{?x,y}", [("x", x), ("y", y)]) == "?x=1024&y=768"
    assert rfc.expand_pairs("{?x,y,empty}",
                            [("x", x), ("y", y),
                             ("empty", empty)]) == "?x=1024&y=768&empty="