From d77b4fc702b4c0e52cb54e6dd927a9aa87e913c4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 27 Oct 2014 22:45:38 +0100 Subject: [PATCH] add tests for accounts package views --- nsupdate/accounts/_tests/__init__.py | 0 nsupdate/accounts/_tests/test_accounts.py | 35 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 nsupdate/accounts/_tests/__init__.py create mode 100644 nsupdate/accounts/_tests/test_accounts.py diff --git a/nsupdate/accounts/_tests/__init__.py b/nsupdate/accounts/_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nsupdate/accounts/_tests/test_accounts.py b/nsupdate/accounts/_tests/test_accounts.py new file mode 100644 index 0000000..89fbf74 --- /dev/null +++ b/nsupdate/accounts/_tests/test_accounts.py @@ -0,0 +1,35 @@ +""" +Tests for accounts views module. +""" + +from __future__ import print_function + +import pytest + +from django.core.urlresolvers import reverse + + +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), + ('account_delete', dict(), 302), + ]: + print("%s, %s, %s" % (view, kwargs, status_code)) + response = client.get(reverse(view, kwargs=kwargs)) + assert response.status_code == status_code + + +def test_views_logged_in(client): + client.login(username=USERNAME, password=PASSWORD) + for view, kwargs, status_code in [ + ('account_profile', dict(), 200), + ('account_delete', dict(), 200), + ]: + print("%s, %s, %s" % (view, kwargs, status_code)) + response = client.get(reverse(view, kwargs=kwargs)) + assert response.status_code == status_code