# HG changeset patch # User Brian Neal # Date 1411611744 18000 # Node ID 704b47356a4934a22f4bc2e314c00741d3db6fae # Parent 5892c05886a94c5c10f6df6bc025ba576aacdd2c Bandmap WIP: made a start on view unit tests. diff -r 5892c05886a9 -r 704b47356a49 bandmap/tests.py --- 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. diff -r 5892c05886a9 -r 704b47356a49 bandmap/tests/test_views.py --- /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"""