bgneal@824: """ bgneal@824: Unit tests for the bandmap application views. bgneal@824: bgneal@824: """ bgneal@824: from django.test import TestCase bgneal@824: from django.core.urlresolvers import reverse bgneal@824: from django.contrib.auth.models import User bgneal@824: bgneal@824: from bandmap.models import BandEntry bgneal@824: bgneal@824: bgneal@824: class NotLoggedInTestCase(TestCase): bgneal@824: """Tests for a non-authenticated user. bgneal@824: bgneal@824: """ bgneal@824: LOGIN_URL = reverse('accounts-login') bgneal@824: bgneal@824: def test_map(self): bgneal@824: url = reverse('bandmap-map') bgneal@824: response = self.client.get(url) bgneal@824: self.assertEqual(response.status_code, 200) bgneal@824: bgneal@824: def test_get_add(self): bgneal@824: url = reverse('bandmap-add') bgneal@824: response = self.client.get(url, follow=True) bgneal@824: self.assertRedirects(response, self.LOGIN_URL + '?next=' + url) bgneal@824: bgneal@824: def test_post_add(self): bgneal@824: url = reverse('bandmap-add') bgneal@824: response = self.client.post(url, follow=True) bgneal@824: self.assertRedirects(response, self.LOGIN_URL + '?next=' + url) bgneal@824: bgneal@824: bgneal@824: class BasicTestCase(TestCase): bgneal@824: """Tests for an authenticated user.""" bgneal@824: bgneal@824: def setUp(self): bgneal@824: self.user = User.objects.create_user( bgneal@824: username='pj', email='pj@example.com', password='top_secret') bgneal@824: self.client.login(username='pj', password='top_secret') bgneal@824: bgneal@824: def test_map(self): bgneal@824: url = reverse('bandmap-map') bgneal@824: response = self.client.get(url) bgneal@824: self.assertEqual(response.status_code, 200) bgneal@824: bgneal@824: def test_get_add(self): bgneal@824: url = reverse('bandmap-add') bgneal@824: response = self.client.get(url, follow=True) bgneal@824: self.assertEqual(response.status_code, 200) bgneal@824: bgneal@824: def test_post_add(self): bgneal@824: """TODO"""