File: test_response.py

package info (click to toggle)
python-cross-web 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 744 kB
  • sloc: python: 2,262; sh: 23; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from cross_web import Response


def test_redirect() -> None:
    response = Response.redirect("https://example.com")
    assert response.status_code == 302
    assert response.headers is not None
    assert response.headers["Location"] == "https://example.com"


def test_redirect_with_query_params() -> None:
    response = Response.redirect("https://example.com", {"a": "1", "b": "2"})
    assert response.status_code == 302
    assert response.headers is not None
    assert response.headers["Location"] == "https://example.com?a=1&b=2"


def test_redirect_with_headers() -> None:
    response = Response.redirect("https://example.com", headers={"X-Test": "test"})
    assert response.status_code == 302
    assert response.headers is not None
    assert response.headers["Location"] == "https://example.com"
    assert response.headers["X-Test"] == "test"