Exemple #1
0
def test_routed_path__with_uuid():
    rp = Route("test").uuid("foo")
    assert (
        rp.to_url() ==
        r"(?P<foo>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})/$"
    )
Exemple #2
0
def test_routed_path__with_optional_uuid():
    rp = Route("test").uuid("foo", optional=True)
    assert (
        rp.to_url() ==
        r"(?P<foo>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})?/?$"
    )
Exemple #3
0
def test_routed_path__with_pk():
    rp = Route("test").pk("foo")
    assert rp.to_url() == r"(?P<foo>[0-9]+)/$"
Exemple #4
0
def test_routed_path__with_optional_pk():
    rp = Route("test").pk("foo", optional=True)
    assert rp.to_url() == r"(?P<foo>[0-9]+)?/?$"
Exemple #5
0
def test_routed_path__with_optional_slug():
    rp = Route("test").slug("foo", optional=True)
    assert rp.to_url() == r"(?P<foo>[\-\w]+)?/?$"
Exemple #6
0
def test_routed_path__with_slug():
    rp = Route("test").slug("foo")
    assert rp.to_url() == r"(?P<foo>[\-\w]+)/$"
Exemple #7
0
def test_routed_path__with_path():
    rp = Route("test").path("foo")
    assert rp.to_url() == r"foo/$"
Exemple #8
0
def test_routed_path__with_many_params():
    rp = Route("test").path("aaa").pk("bbb").path("ccc").slug("ddd")
    assert rp.to_url() == r"aaa/(?P<bbb>[0-9]+)/ccc/(?P<ddd>[\-\w]+)/$"
Exemple #9
0
def test_routed_path__with_no_params():
    rp = Route("test")
    assert rp.to_url() == r"$"