Skip to content

Commit 3f2f4dc

Browse files
authored
Merge pull request #5 from olyapka84/codex/investigate-code-coverage-drop-0lkw6v
Expand coverage for translated user flows
2 parents e45246f + a6aba4c commit 3f2f4dc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

task_manager/users/tests.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,38 @@ def test_registration_get(client):
5151
assert 'name="password2"' in html
5252

5353

54+
@pytest.mark.django_db
55+
def test_registration_form_english_texts(client):
56+
response = client.get(reverse("users:create"))
57+
assert response.status_code == 200
58+
59+
html = response.content.decode()
60+
assert "First name" in html
61+
assert "Last name" in html
62+
assert "Password confirmation" in html
63+
64+
65+
@pytest.mark.django_db
66+
def test_login_page_uses_custom_authentication_form(client):
67+
response = client.get(reverse("login"))
68+
assert response.status_code == 200
69+
70+
html = response.content.decode()
71+
assert "Log in" in html
72+
assert "Username" in html
73+
assert "Password" in html
74+
75+
76+
@pytest.mark.django_db
77+
def test_logout_view_logs_user_out(auth_client):
78+
response = auth_client.post(reverse("logout"))
79+
assert response.status_code in (302, 301)
80+
81+
# The logout view should end the session, so following requests must be anonymous
82+
follow_up = auth_client.get(reverse("home"))
83+
assert follow_up.wsgi_request.user.is_anonymous
84+
85+
5486
@pytest.mark.django_db
5587
def test_registration_post_creates_user(client):
5688
data = {
@@ -79,6 +111,10 @@ def test_user_can_update_self(auth_client, users):
79111
url = reverse("users:update", args=[users["alice"].pk])
80112
r_get = auth_client.get(url)
81113
assert r_get.status_code == 200
114+
html = r_get.content.decode()
115+
assert "Password" in html
116+
assert "Password confirmation" in html
117+
assert "Please enter the password again for confirmation." in html
82118

83119
r_post = auth_client.post(
84120
url,

0 commit comments

Comments
 (0)