1caa36e4a6dd8ac3653439d8c58e7f6f587995be
[mygpo.git] / mygpo / core / tests.py
blob1caa36e4a6dd8ac3653439d8c58e7f6f587995be
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
23 import mygpo.utils
24 from mygpo.core.models import Podcast, PodcastGroup
27 class PodcastGroupTests(unittest.TestCase):
29 def test_group(self):
30 self.podcast1 = Podcast(urls=['http://example1.com'])
31 self.podcast1.save()
33 self.podcast2 = Podcast(urls=['http://example2.com'])
34 self.podcast2.save()
36 group = self.podcast1.group_with(self.podcast2, 'My Group', 'p1', 'p2')
38 self.assertIn(self.podcast1, group.podcasts)
39 self.assertIn(self.podcast2, group.podcasts)
40 self.assertEquals(len(group.podcasts), 2)
41 self.assertEquals(group.title, 'My Group')
42 self.assertEquals(self.podcast1.group_member_name, 'p1')
43 self.assertEquals(self.podcast2.group_member_name, 'p2')
45 # add to group
46 self.podcast3 = Podcast(urls=['http://example3.com'])
47 self.podcast3.save()
49 group = self.podcast1.group_with(self.podcast3, 'My Group', 'p1', 'p3')
51 self.assertIn(self.podcast3, group.podcasts)
52 self.assertEquals(self.podcast3.group_member_name, 'p3')
54 # add group to podcast
55 self.podcast4 = Podcast(urls=['http://example4.com'])
56 self.podcast4.save()
58 group = self.podcast4.group_with(self.podcast1, 'My Group', 'p4', 'p1')
60 self.assertIn(self.podcast4, group.podcasts)
61 self.assertEquals(self.podcast4.group_member_name, 'p4')
65 def suite():
66 suite = unittest.TestSuite()
67 suite.addTest(doctest.DocTestSuite(mygpo.utils))
68 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(PodcastGroupTests))
69 return suite