-
Notifications
You must be signed in to change notification settings - Fork 0
/
podcast_gen_test.py
executable file
·67 lines (59 loc) · 2.16 KB
/
podcast_gen_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# coding: utf-8
# vim:set ts=2 sts=2 sw=2:
import unittest
import podcast_gen
class PodcastGenUnitTest(unittest.TestCase):
"""A rudimentary unit test."""
def testSubdirectoryOfPublicHtml(self):
self.maxDiff = None
config = {
'general': {
'input_dir': '/home/joe/public_html/bar',
'output_file': '/home/joe/public_html/bar/feed.xml',
'base_url': 'http://baz.com/~joe/bar',
'feed_url': 'http://baz.com/~joe/bar/feed.xml',
'base_host': 'baz.com',
'base_url_path': '/~joe/bar',
},
'channel': {
'title': 'Bar',
'description': "Podcast generated from '/home/joe/public_html/bar'",
},
'iTunes': {
'image': 'http://baz.com/~joe/bar/cover.jpg'
},
}
self.assertEqual(config,
podcast_gen.ComposeConfig(
"/home/joe/public_html/bar", "baz.com", "joe"))
def testSubSubdirectoryOfPublicHtml(self):
self.maxDiff = None
config = {
'general': {
'input_dir': '/home/joe/public_html/foo/bar',
'output_file': '/home/joe/public_html/foo/bar/feed.xml',
'base_url': 'http://baz.com/~joe/foo/bar',
'feed_url': 'http://baz.com/~joe/foo/bar/feed.xml',
'base_host': 'baz.com',
'base_url_path': '/~joe/foo/bar',
},
'channel': {
'title': 'Bar',
'description': "Podcast generated from '/home/joe/public_html/foo/bar'",
},
'iTunes': {
'image': 'http://baz.com/~joe/foo/bar/cover.jpg'
},
}
self.assertEqual(config,
podcast_gen.ComposeConfig(
"/home/joe/public_html/foo/bar", "baz.com", "joe"))
def testGetPathAfterPublicHtml(self):
self.assertEqual('foo/bar',
podcast_gen._GetPathAfterPublicHtml('/home/joe/public_html/foo/bar'))
def testGetPathAfterPublicHtmlNoPublicHtml(self):
self.assertEqual('/home/joe/missing/foo/bar',
podcast_gen._GetPathAfterPublicHtml('/home/joe/missing/foo/bar'))
if __name__ == '__main__':
unittest.main()