How to use the rfc3986.builder.URIBuilder function in rfc3986

To help you get started, we’ve selected a few rfc3986 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_finalize():
    """Verify the whole thing."""
    uri = (
        builder.URIBuilder()
        .add_scheme("https")
        .add_credentials("sigmavirus24", "not-my-re@l-password")
        .add_host("github.com")
        .add_path("sigmavirus24/rfc3986")
        .finalize()
        .unsplit()
    )
    expected = (
        "https://sigmavirus24:not-my-re%40l-password@github.com/"
        "sigmavirus24/rfc3986"
    )
    assert expected == uri
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_from_uri_reference():
    uri = uri_reference("http://foo.bar:1234/baz")
    uribuilder = builder.URIBuilder().from_uri(uri)
    assert uribuilder.scheme == "http"
    assert uribuilder.userinfo is None
    assert uribuilder.host == "foo.bar"
    assert uribuilder.port == "1234"
    assert uribuilder.path == "/baz"
    assert uribuilder.query is None
    assert uribuilder.fragment is None
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_add_invalid_port(port):
    """Verify we raise a ValueError for invalid ports."""
    with pytest.raises(ValueError):
        builder.URIBuilder().add_port(port)
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_add_fragment():
    """Verify our handling of fragments."""
    uribuilder = builder.URIBuilder().add_fragment("section-2.5.1")
    assert uribuilder.fragment == "section-2.5.1"
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_add_credentials_requires_username():
    """Verify one needs a username to add credentials."""
    with pytest.raises(ValueError):
        builder.URIBuilder().add_credentials(None, None)
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_add_port(port, expected):
    """Verify we normalize our port."""
    uribuilder = builder.URIBuilder().add_port(port)
    assert uribuilder.port == expected
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_from_uri_string():
    uribuilder = builder.URIBuilder().from_uri("https://bar.foo:4321/boom")
    assert uribuilder.scheme == "https"
    assert uribuilder.userinfo is None
    assert uribuilder.host == "bar.foo"
    assert uribuilder.port == "4321"
    assert uribuilder.path == "/boom"
    assert uribuilder.query is None
    assert uribuilder.fragment is None
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_add_path(path):
    """Verify we normalize our path value."""
    uribuilder = builder.URIBuilder().add_path(path)
    assert uribuilder.path == "/sigmavirus24/rfc3986"
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_extend_query_with(uri, extend_with, expected_query):
    """Verify the behaviour of extend_query_with."""
    uribuilder = (
        builder.URIBuilder()
        .from_uri(uri_reference(uri))
        .extend_query_with(extend_with)
    )
    assert parse_qs(uribuilder.query) == expected_query