bgneal@824
|
1 """
|
bgneal@824
|
2 Unit tests for the bandmap application views.
|
bgneal@824
|
3
|
bgneal@824
|
4 """
|
bgneal@824
|
5 from django.test import TestCase
|
bgneal@824
|
6 from django.core.urlresolvers import reverse
|
bgneal@824
|
7 from django.contrib.auth.models import User
|
bgneal@824
|
8
|
bgneal@824
|
9 from bandmap.models import BandEntry
|
bgneal@824
|
10
|
bgneal@824
|
11
|
bgneal@824
|
12 class NotLoggedInTestCase(TestCase):
|
bgneal@824
|
13 """Tests for a non-authenticated user.
|
bgneal@824
|
14
|
bgneal@824
|
15 """
|
bgneal@824
|
16 LOGIN_URL = reverse('accounts-login')
|
bgneal@824
|
17
|
bgneal@824
|
18 def test_map(self):
|
bgneal@824
|
19 url = reverse('bandmap-map')
|
bgneal@824
|
20 response = self.client.get(url)
|
bgneal@824
|
21 self.assertEqual(response.status_code, 200)
|
bgneal@824
|
22
|
bgneal@824
|
23 def test_get_add(self):
|
bgneal@824
|
24 url = reverse('bandmap-add')
|
bgneal@824
|
25 response = self.client.get(url, follow=True)
|
bgneal@824
|
26 self.assertRedirects(response, self.LOGIN_URL + '?next=' + url)
|
bgneal@824
|
27
|
bgneal@824
|
28 def test_post_add(self):
|
bgneal@824
|
29 url = reverse('bandmap-add')
|
bgneal@824
|
30 response = self.client.post(url, follow=True)
|
bgneal@824
|
31 self.assertRedirects(response, self.LOGIN_URL + '?next=' + url)
|
bgneal@824
|
32
|
bgneal@824
|
33
|
bgneal@824
|
34 class BasicTestCase(TestCase):
|
bgneal@824
|
35 """Tests for an authenticated user."""
|
bgneal@824
|
36
|
bgneal@824
|
37 def setUp(self):
|
bgneal@824
|
38 self.user = User.objects.create_user(
|
bgneal@824
|
39 username='pj', email='pj@example.com', password='top_secret')
|
bgneal@824
|
40 self.client.login(username='pj', password='top_secret')
|
bgneal@824
|
41
|
bgneal@824
|
42 def test_map(self):
|
bgneal@824
|
43 url = reverse('bandmap-map')
|
bgneal@824
|
44 response = self.client.get(url)
|
bgneal@824
|
45 self.assertEqual(response.status_code, 200)
|
bgneal@824
|
46
|
bgneal@824
|
47 def test_get_add(self):
|
bgneal@824
|
48 url = reverse('bandmap-add')
|
bgneal@824
|
49 response = self.client.get(url, follow=True)
|
bgneal@824
|
50 self.assertEqual(response.status_code, 200)
|
bgneal@824
|
51
|
bgneal@824
|
52 def test_post_add(self):
|
bgneal@824
|
53 """TODO"""
|