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="
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="
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"
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="
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}"
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}"
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"
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"
def test_fragment_expansion(): assert rfc.expand_segments("X{#var}", [var]) == "X#value" assert rfc.expand_segments("X{#hello}", [hello]) == "X#Hello%20World!"
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"
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"
def test_fragment_expansion(): assert rfc.expand_segments("X{#var}", [var]) == "X#value" assert rfc.expand_segments("X{#hello}", [hello]) == "X#Hello%20World!"
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"
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
def test_simple_string_expansion(): assert rfc.expand_segments("{var}", [var]) == "value" assert rfc.expand_segments("{hello}", [hello]) == "Hello%20World%21"
def test_simple_string_expansion(): assert rfc.expand_segments("{var}", [var]) == "value" assert rfc.expand_segments("{hello}", [hello]) == "Hello%20World%21"
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"
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"
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"
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"
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"
def test_path_segments(): assert rfc.expand_segments("{/var}", [var]) == "/value" assert rfc.expand_segments("{/var,x}/here", [var, x]) == "/value/1024/here"
def test_path_segments(): assert rfc.expand_segments("{/var}", [var]) == "/value" assert rfc.expand_segments("{/var,x}/here", [var, x]) == "/value/1024/here"
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"
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"
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="