generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pages.py
38 lines (28 loc) · 1.41 KB
/
test_pages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def test_set_locale(app, client):
response = client.get("/locale/cy", headers={"referer": "http://localhost/privacy"})
assert response.status_code == 302
assert response.headers["location"] == "/privacy"
cookies = response.headers["Set-Cookie"].split(";")
assert "locale=cy" in cookies, "Could not find locale cookie"
def test_set_locale_invalid(app, client):
response = client.get("/locale/de", headers={"referer": "http://localhost/privacy"})
assert response.status_code == 404, f"Expecting 404 got {response.status_code}"
def test_service_unavailable_on(app, client):
app.config["SERVICE_UNAVAILABLE"] = True
response = client.get("/")
assert response.status_code == 302
assert response.headers["location"] == "/service-unavailable"
response = client.get("/", follow_redirects=True)
assert response.status_code == 503
assert response.request.path == "/service-unavailable"
def test_service_unavailable_off(app, client):
app.config["SERVICE_UNAVAILABLE"] = False
response = client.get("/service-unavailable", follow_redirects=True)
assert response.status_code == 200
assert response.request.path == "/find-your-problem"
def test_header_link_clears_session(app, client):
with client.session_transaction() as session:
session["test"] = "test"
client.get("/")
with client.session_transaction() as session:
assert "test" not in session