changeset 824:704b47356a49

Bandmap WIP: made a start on view unit tests.
author Brian Neal <bgneal@gmail.com>
date Wed, 24 Sep 2014 21:22:24 -0500 (2014-09-25)
parents 5892c05886a9
children d91356818cef
files bandmap/tests.py bandmap/tests/__init__.py bandmap/tests/test_views.py
diffstat 2 files changed, 53 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/bandmap/tests.py	Wed Sep 24 20:09:05 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bandmap/tests/test_views.py	Wed Sep 24 21:22:24 2014 -0500
@@ -0,0 +1,53 @@
+"""
+Unit tests for the bandmap application views.
+
+"""
+from django.test import TestCase
+from django.core.urlresolvers import reverse
+from django.contrib.auth.models import User
+
+from bandmap.models import BandEntry
+
+
+class NotLoggedInTestCase(TestCase):
+    """Tests for a non-authenticated user.
+
+    """
+    LOGIN_URL = reverse('accounts-login')
+
+    def test_map(self):
+        url = reverse('bandmap-map')
+        response = self.client.get(url)
+        self.assertEqual(response.status_code, 200)
+
+    def test_get_add(self):
+        url = reverse('bandmap-add')
+        response = self.client.get(url, follow=True)
+        self.assertRedirects(response, self.LOGIN_URL + '?next=' + url)
+
+    def test_post_add(self):
+        url = reverse('bandmap-add')
+        response = self.client.post(url, follow=True)
+        self.assertRedirects(response, self.LOGIN_URL + '?next=' + url)
+
+
+class BasicTestCase(TestCase):
+    """Tests for an authenticated user."""
+
+    def setUp(self):
+        self.user = User.objects.create_user(
+            username='pj', email='pj@example.com', password='top_secret')
+        self.client.login(username='pj', password='top_secret')
+
+    def test_map(self):
+        url = reverse('bandmap-map')
+        response = self.client.get(url)
+        self.assertEqual(response.status_code, 200)
+
+    def test_get_add(self):
+        url = reverse('bandmap-add')
+        response = self.client.get(url, follow=True)
+        self.assertEqual(response.status_code, 200)
+
+    def test_post_add(self):
+        """TODO"""