pep8-ify some code
[mygpo.git] / mygpo / web / tests.py
blob4f40da796814a9509d99365e02610d70a4a7c918
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.test import create_auth_string
28 class SimpleWebTests(TestCase):
29 def setUp(self):
30 self.user, _ = User.objects.get_or_create(username='test')
31 self.user.set_password('pwd')
32 self.user.save()
34 self.auth_string = create_auth_string('test', 'pwd')
36 def test_access_parameterless_pages(self):
37 pages = [
38 'history',
39 'suggestions',
40 'tags',
41 'help',
42 'subscriptions',
43 'subscriptions-opml',
44 'subscriptions-download',
45 'favorites',
46 'account',
47 'privacy',
48 'delete-account',
49 'share',
50 'toplist',
51 'episode-toplist',
52 'devices',
53 'device-create',
54 'login',
55 'logout',
56 'home']
58 self.access_pages(pages, [], True)
60 def test_access_podcast_pages(self):
61 pages = ['podcast', ]
63 def access_pages(self, pages, args, login):
64 if login:
65 self.client.post('/login/', dict(
66 login_username=self.user.username, pwd='pwd'))
68 for page in pages:
69 response = self.client.get(reverse(page, args=args), follow=True)
70 self.assertEquals(response.status_code, 200)
73 def suite():
74 suite = unittest.TestSuite()
75 suite.addTest(doctest.DocTestSuite(mygpo.web.utils))
76 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(SimpleWebTests))
77 return suite