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/>.
21 from django
.test
import TestCase
24 from mygpo
.core
.slugs
import get_duplicate_slugs
25 from mygpo
.core
.models
import Episode
28 class UnifySlugTests(unittest
.TestCase
):
32 from mygpo
.core
.models
import Episode
33 a
= Episode(_id
='a', slug
='1')
34 b
= Episode(_id
='b', merged_slugs
=['1'])
35 c
= Episode(_id
='c', merged_slugs
=['1'])
37 dups_list
= list(get_duplicate_slugs([a
, b
, c
]))
39 # only one duplicate slug is reported
40 self
.assertEquals(len(dups_list
), 1)
42 slug
, dups
= dups_list
[0]
44 self
.assertEquals(slug
, '1')
45 self
.assertEquals(len(dups
), 2)
46 self
.assertEquals(dups
[0], b
)
47 self
.assertEquals(dups
[1], c
)
48 self
.assertEquals(dups
, [b
, c
])
52 suite
= unittest
.TestSuite()
53 suite
.addTest(doctest
.DocTestSuite(mygpo
.utils
))
54 suite
.addTest(unittest
.TestLoader().loadTestsFromTestCase(UnifySlugTests
))