simplify some @repeat_on_conflict decorated methods
[mygpo.git] / mygpo / web / tests.py
blob74e050e04a894b60d984414c38c05bf3c2ba8eaf
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')
37 def test_access_parameterless_pages(self):
38 pages = [
39 'history',
40 'suggestions',
41 'tags',
42 'help',
43 'subscriptions',
44 'subscriptions-opml',
45 'subscriptions-download',
46 'favorites',
47 'account',
48 'privacy',
49 'delete-account',
50 'share',
51 'toplist',
52 'episode-toplist',
53 'devices',
54 'device-create',
55 'login',
56 'logout',
57 'home']
59 self.access_pages(pages, [], True)
62 def test_access_podcast_pages(self):
63 pages = ['podcast', ]
66 def access_pages(self, pages, args, login):
67 if login:
68 self.client.post('/login/',
69 dict(login_username=self.user.username, pwd='pwd'))
71 for page in pages:
72 response = self.client.get(reverse(page, args=args), follow=True)
73 self.assertEquals(response.status_code, 200)
76 def suite():
77 suite = unittest.TestSuite()
78 suite.addTest(doctest.DocTestSuite(mygpo.web.utils))
79 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(SimpleWebTests))
80 return suite