fix typo
[mygpo.git] / mygpo / web / tests.py
blob62fad6387636feb9523e1ba5e4419f65b3114ec5
2 # This file is part of my.gpodder.org.
4 # my.gpodder.org is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # my.gpodder.org is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
12 # License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
18 import unittest
19 import doctest
21 from django.test import TestCase
22 from django.core.urlresolvers import reverse
24 import mygpo.web.utils
25 from mygpo.users.models import User
26 from mygpo.test import create_auth_string
29 class SimpleWebTests(TestCase):
31 @classmethod
32 def setUpClass(self):
33 self.user = User(username='web-test', email='web-test@example.com')
34 self.user.set_password('pwd')
35 self.user.save()
37 self.auth_string = create_auth_string('test', 'pwd')
39 @classmethod
40 def tearDownClass(self):
41 self.user.delete()
43 def test_access_parameterless_pages(self):
44 pages = [
45 'history',
46 'suggestions',
47 'tags',
48 'subscriptions',
49 'subscriptions-opml',
50 'subscriptions-download',
51 'favorites',
52 'account',
53 'privacy',
54 'delete-account',
55 'share',
56 'toplist',
57 'episode-toplist',
58 'devices',
59 'device-create',
60 'login',
61 'logout',
62 'home']
64 self.access_pages(pages, [], True)
66 def test_access_podcast_pages(self):
67 pages = ['podcast', ]
69 def access_pages(self, pages, args, login):
70 if login:
71 self.client.post('/login/', dict(
72 login_username=self.user.username, pwd='pwd'))
74 for page in pages:
75 response = self.client.get(reverse(page, args=args), follow=True)
76 self.assertEquals(response.status_code, 200)
79 def suite():
80 suite = unittest.TestSuite()
81 suite.addTest(doctest.DocTestSuite(mygpo.web.utils))
82 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(SimpleWebTests))
83 return suite