44 lines
1.4 KiB
Python
Raw Normal View History

2014-10-27 22:45:38 +01:00
"""
Tests for accounts views module.
"""
from __future__ import print_function
import pytest
2017-12-28 17:12:34 +01:00
from django.urls import reverse
2014-10-27 22:45:38 +01:00
USERNAME = 'test'
PASSWORD = 'pass'
def test_views_anon(client):
for view, kwargs, status_code in [
# stuff that requires being logged-in redirects to the login view:
('account_profile', dict(), 302),
2015-01-02 13:19:51 +01:00
('account_settings', dict(), 302),
2014-10-27 22:45:38 +01:00
('account_delete', dict(), 302),
2015-01-02 13:19:51 +01:00
('registration_disallowed', dict(), 200),
('registration_complete', dict(), 200),
('registration_register', dict(), 200),
('registration_activation_complete', dict(), 200),
2014-10-27 22:45:38 +01:00
]:
print("%s, %s, %s" % (view, kwargs, status_code))
response = client.get(reverse(view, kwargs=kwargs))
assert response.status_code == status_code
2017-12-28 23:38:21 +01:00
@pytest.mark.parametrize("view,view_kwargs,status_code", (
('account_profile', dict(), 200),
('account_settings', dict(), 200),
('account_delete', dict(), 200),
('registration_disallowed', dict(), 200),
('registration_complete', dict(), 200),
('registration_register', dict(), 302),
('registration_activation_complete', dict(), 200),
))
def test_views_logged_in(client, view, view_kwargs, status_code):
assert client.login(username=USERNAME, password=PASSWORD)
response = client.get(reverse(view, kwargs=view_kwargs))
assert response.status_code == status_code