Ejemplo n.º 1
0
def test_accept() -> None:
    accept = Accept(
        'application/vnd.google-earth.kml+xml;googleearth=context.kml,'
        'application/vnd.google-earth.kmz;googleearth=context.kmz;q=0.7'
    )
    assert accept.options == [
        AcceptOption('application/vnd.google-earth.kml+xml', 1.0, {'googleearth': 'context.kml'}),
        AcceptOption('application/vnd.google-earth.kmz', 0.7, {'googleearth': 'context.kmz'}),
    ]
Ejemplo n.º 2
0
def test_accept() -> None:
    accept = Accept(
        "application/vnd.google-earth.kml+xml;googleearth=context.kml,"
        "application/vnd.google-earth.kmz;googleearth=context.kmz;q=0.7")
    assert accept.options == [
        AcceptOption("application/vnd.google-earth.kml+xml", 1.0,
                     {"googleearth": "context.kml"}),
        AcceptOption("application/vnd.google-earth.kmz", 0.7,
                     {"googleearth": "context.kmz"}),
    ]
Ejemplo n.º 3
0
def test_accept___getitem__() -> None:  # noqa: N807
    accept = Accept('gzip, deflate, br;q=0.9, *;q=0.8')
    assert accept["gzip"] == 1.0
    assert accept["bizarre"] == 0.8
Ejemplo n.º 4
0
def test_accept_quality() -> None:
    accept = Accept('gzip, deflate, br;q=0.9')
    assert accept.quality("gzip") == 1.0
    assert accept.quality("bizarre") == 0.0
Ejemplo n.º 5
0
def test_accept_best_match() -> None:
    accept = Accept('gzip, deflate, br;q=0.9, *;q=0.8')
    assert accept.best_match(['gzip', 'defalte']) == 'gzip'
    assert accept.best_match(['br', 'deflate']) == 'deflate'
    assert accept.best_match(['bizarre']) == 'bizarre'
Ejemplo n.º 6
0
def test_accept___contains__() -> None:  # noqa: N807
    accept = Accept('gzip, deflate, br;q=0.9, *;q=0.8')
    assert "gzip" in accept
    assert "bizzare" in accept
Ejemplo n.º 7
0
def test_accept_best() -> None:
    accept = Accept("gzip, deflate, br;q=0.9, *;q=0.8")
    assert accept.best == "gzip"
Ejemplo n.º 8
0
def test_accept_best_match() -> None:
    accept = Accept("gzip, deflate, br;q=0.9, *;q=0.8")
    assert accept.best_match(["gzip", "defalte"]) == "gzip"
    assert accept.best_match(["br", "deflate"]) == "deflate"
    assert accept.best_match(["bizarre"]) == "bizarre"