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