Exemplo n.º 1
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.º 2
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.º 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_pairs():
    assert rfc.expand_pairs("{;x}", []) == ""
    assert rfc.expand_pairs("{;x,y}", []) == ""
    assert rfc.expand_pairs("{;x}", [], partial=True) == "{;x}"
    assert rfc.expand_pairs("{;x,y}", [("x", x)]) == ";x=1024"
    assert rfc.expand_pairs("{;x,y}", [("x", x)], partial=True) == ";x=1024{;y}"
    assert rfc.expand_pairs("{;x,y}", [("y", y)], partial=True) == ";y=768{;x}"
    assert rfc.expand_pairs("{;x,y,empty}", [("y", y)], partial=True) == ";y=768{;x,empty}"
    assert rfc.expand_pairs("{;x,y,empty}", [("y", y), ("x", x)], partial=True) == ";y=768;x=1024{;empty}"
Exemplo n.º 6
0
def test_partial_pairs():
    assert rfc.expand_pairs("{;x}", []) == ""
    assert rfc.expand_pairs("{;x,y}", []) == ""
    assert rfc.expand_pairs("{;x}", [], partial=True) == "{;x}"
    assert rfc.expand_pairs("{;x,y}", [("x", x)]) == ";x=1024"
    assert rfc.expand_pairs("{;x,y}", [("x", x)],
                            partial=True) == ";x=1024{;y}"
    assert rfc.expand_pairs("{;x,y}", [("y", y)], partial=True) == ";y=768{;x}"
    assert rfc.expand_pairs("{;x,y,empty}", [("y", y)],
                            partial=True) == ";y=768{;x,empty}"
    assert rfc.expand_pairs("{;x,y,empty}", [("y", y), ("x", x)],
                            partial=True) == ";y=768;x=1024{;empty}"
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
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