Skip to content

Commit 2c16cd1

Browse files
author
Ian Noyes
committed
unit tests
1 parent 8c002a1 commit 2c16cd1

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
2+
<channel>
3+
4+
<itunes:category text="News">
5+
<itunes:category text="Business News"/>
6+
</itunes:category>
7+
<itunes:category text="Health"/>
8+
<copyright>basic copyright</copyright>
9+
<description>basic description</description>
10+
<generator>an infinite monkeys</generator>
11+
<image>
12+
<title>Test Image</title>
13+
<url>https://test/giffy.jpg</url>
14+
<link>https://test</link>
15+
<width>1000</width>
16+
<height>5000</height>
17+
</image>
18+
<language>basic language</language>
19+
<lastBuildDate>Mon, 24 Mar 2008 23:30:07 GMT</lastBuildDate>
20+
<link>https://github.com/iheartradio/pyPodcastParser</link>]
21+
<atom:link href="https://bubpubsubhub.appspot.com" />
22+
<atom:link rel="buh" href="https://bubpubsubhub.appspot.com" />
23+
<atom:link href="https://pubsubhubbub.appspot.com" />
24+
25+
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
26+
27+
<atom:link />
28+
29+
<atom:link href="https://bubpubsubhub.pspot.com" />
30+
<atom:link rel="buh" href="https://bubpubsuhub.appspot.com" />
31+
<atom:link href="https://pubsubhbub.appspot.com" />
32+
<managingEditor>nobody</managingEditor>
33+
<pubDate>"Mon, 24 Mar 2008 23:30:07 GMT"</pubDate>
34+
<title>basic title</title>
35+
<ttl>60</ttl>
36+
<webMaster>webrobot</webMaster>
37+
38+
<itunes:author>basic itunes author</itunes:author>
39+
<itunes:complete>yes</itunes:complete>
40+
<itunes:explicit>clean</itunes:explicit>
41+
<itunes:image href="https://github.com/iheartradio/pyPodcastParser.jpg"/>
42+
<itunes:keywords>Python, Testing</itunes:keywords>
43+
<itunes:new-feed-url>http://newlocation.com/example.rss</itunes:new-feed-url>
44+
<itunes:owner>
45+
<itunes:email>basic itunes owner email</itunes:email>
46+
<itunes:name>basic itunes owner name</itunes:name>
47+
</itunes:owner>
48+
<itunes:subtitle>basic itunes subtitle</itunes:subtitle>
49+
<itunes:summary>basic itunes summary</itunes:summary>
50+
<itunes:type>FULL</itunes:type>
51+
<item>
52+
53+
<author>lawyer@boyer.net</author>
54+
<category>Grateful Dead</category>
55+
<category>Stones</category>
56+
<comments>http://comments.com/entry/0</comments>
57+
<creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/1.0</creativeCommons:license>
58+
<description><p><em>basic item description</p></em></description>
59+
<guid isPermaLink="true">basic item guid</guid>
60+
<link>http://google.com/0</link>
61+
<pubDate>Fri, 21 Mar 2008 09:51:00 EDT</pubDate>
62+
<title>basic item title</title>
63+
64+
<enclosure length="123456" url="https://github.com/iheartradio/pyPodcastParser.mp3" type="audio/mpeg"/>
65+
66+
<itunes:author>basic item itunes author</itunes:author>
67+
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
68+
<itunes:duration>1:05</itunes:duration>
69+
<itunes:explicit>no</itunes:explicit>
70+
<itunes:image href="http://poo.poo/gif.jpg"/>
71+
<itunes:keywords/>
72+
<itunes:order>2</itunes:order>
73+
<itunes:subtitle>The Subtitle</itunes:subtitle>
74+
<itunes:summary>The Summary</itunes:summary>
75+
76+
77+
</item>
78+
79+
<item>
80+
81+
<author>lawyer@boyer.net (Lawyer Boyer)</author>
82+
<category>Dead and Grateful</category>
83+
<category>News</category>
84+
<comments>http://comments.com/entry/1</comments>
85+
<description>another basic item description</description>
86+
<guid isPermaLink="true">another basic item guid</guid>
87+
<link>http://google.com/1</link>
88+
<pubDate>Fri, 21 Mar 201208 09:50:00 EDT</pubDate>
89+
<title>another basic item title</title>
90+
91+
<enclosure length="123456" url="https://github.com/iheartradio/pyPodcastParser.mp3" type="audio/mpeg"/>
92+
93+
<itunes:author>another basic item itunes author</itunes:author>
94+
<itunes:duration>1:11:05</itunes:duration>
95+
<itunes:explicit>clean</itunes:explicit>
96+
<itunes:image href="http://poo.poo/gif.jpg"/>
97+
<itunes:keywords/>
98+
<itunes:order>1</itunes:order>
99+
<itunes:subtitle>Another Subtitle</itunes:subtitle>
100+
<itunes:summary>Another Summary</itunes:summary>
101+
102+
</item>
103+
</channel>
104+
</rss>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
2+
<channel>
3+
4+
<itunes:category text="News">
5+
<itunes:category text="Business News"/>
6+
</itunes:category>
7+
<itunes:category text="Health"/>
8+
<copyright>basic copyright</copyright>
9+
<description>basic description</description>
10+
<generator>an infinite monkeys</generator>
11+
<image>
12+
<title>Test Image</title>
13+
<url>https://test/giffy.jpg</url>
14+
<link>https://test</link>
15+
<width>1000</width>
16+
<height>5000</height>
17+
</image>
18+
<language>basic language</language>
19+
<lastBuildDate>Mon, 24 Mar 2008 23:30:07 GMT</lastBuildDate>
20+
<link>https://github.com/iheartradio/pyPodcastParser</link>]
21+
<atom:link href="https://bubpubsubhub.appspot.com" />
22+
<atom:link rel="buh" href="https://bubpubsubhub.appspot.com" />
23+
<atom:link href="https://pubsubhubbub.appspot.com" />
24+
25+
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
26+
27+
<atom:link />
28+
29+
<atom:link href="https://bubpubsubhub.pspot.com" />
30+
<atom:link rel="buh" href="https://bubpubsuhub.appspot.com" />
31+
<atom:link href="https://pubsubhbub.appspot.com" />
32+
<managingEditor>nobody</managingEditor>
33+
<pubDate>"2022-2022-2202-020202"</pubDate>
34+
<title>basic title</title>
35+
<ttl>60</ttl>
36+
<webMaster>webrobot</webMaster>
37+
38+
<itunes:author>basic itunes author</itunes:author>
39+
<itunes:complete>yes</itunes:complete>
40+
<itunes:explicit>clean</itunes:explicit>
41+
<itunes:image href="https://github.com/iheartradio/pyPodcastParser.jpg"/>
42+
<itunes:keywords>Python, Testing</itunes:keywords>
43+
<itunes:new-feed-url>http://newlocation.com/example.rss</itunes:new-feed-url>
44+
<itunes:owner>
45+
<itunes:email>basic itunes owner email</itunes:email>
46+
<itunes:name>basic itunes owner name</itunes:name>
47+
</itunes:owner>
48+
<itunes:subtitle>basic itunes subtitle</itunes:subtitle>
49+
<itunes:summary>basic itunes summary</itunes:summary>
50+
<itunes:type>FULL</itunes:type>
51+
<item>
52+
53+
<author>lawyer@boyer.net</author>
54+
<category>Grateful Dead</category>
55+
<category>Stones</category>
56+
<comments>http://comments.com/entry/0</comments>
57+
<creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/1.0</creativeCommons:license>
58+
<description><p><em>basic item description</p></em></description>
59+
<guid isPermaLink="true">basic item guid</guid>
60+
<link>http://google.com/0</link>
61+
<pubDate>Fri, 21 Mar 2008 09:51:00 EDT</pubDate>
62+
<title>basic item title</title>
63+
64+
<enclosure length="123456" url="https://github.com/iheartradio/pyPodcastParser.mp3" type="audio/mpeg"/>
65+
66+
<itunes:author>basic item itunes author</itunes:author>
67+
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
68+
<itunes:duration>1:05</itunes:duration>
69+
<itunes:explicit>no</itunes:explicit>
70+
<itunes:image href="http://poo.poo/gif.jpg"/>
71+
<itunes:keywords/>
72+
<itunes:order>2</itunes:order>
73+
<itunes:subtitle>The Subtitle</itunes:subtitle>
74+
<itunes:summary>The Summary</itunes:summary>
75+
76+
77+
</item>
78+
79+
<item>
80+
81+
<author>lawyer@boyer.net (Lawyer Boyer)</author>
82+
<category>Dead and Grateful</category>
83+
<category>News</category>
84+
<comments>http://comments.com/entry/1</comments>
85+
<description>another basic item description</description>
86+
<guid isPermaLink="true">another basic item guid</guid>
87+
<link>http://google.com/1</link>
88+
<pubDate>Fri, 21 Mar 2008 09:50:00 EDT</pubDate>
89+
<title>another basic item title</title>
90+
91+
<enclosure length="123456" url="https://github.com/iheartradio/pyPodcastParser.mp3" type="audio/mpeg"/>
92+
93+
<itunes:author>another basic item itunes author</itunes:author>
94+
<itunes:duration>1:11:05</itunes:duration>
95+
<itunes:explicit>clean</itunes:explicit>
96+
<itunes:image href="http://poo.poo/gif.jpg"/>
97+
<itunes:keywords/>
98+
<itunes:order>1</itunes:order>
99+
<itunes:subtitle>Another Subtitle</itunes:subtitle>
100+
<itunes:summary>Another Summary</itunes:summary>
101+
102+
</item>
103+
</channel>
104+
</rss>

tests/test_pyPodcastParser.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,5 +616,34 @@ def test_episode_parsing_transcription_data_episode_transcription(self):
616616
)
617617

618618

619+
class TestInvalidPodcastFeed(unittest.TestCase):
620+
def setUp(self):
621+
test_dir = os.path.dirname(__file__)
622+
test_feeds_dir = os.path.join(test_dir, "test_feeds")
623+
invalid_podcast_path = os.path.join(test_feeds_dir, "invalid_show_dates.rss")
624+
invalid_podcast_file = open(invalid_podcast_path, "rb")
625+
self.invalid_podcast = invalid_podcast_file.read()
626+
627+
def test_invalid_podcast_feed(self):
628+
with self.assertRaises(Podcast.InvalidPodcastFeed) as context:
629+
Podcast.Podcast(self.invalid_podcast)
630+
self.assertTrue('Invalid Podcast Feed, show level pubDate: "2022-2022-2202-020202", could not be parsed' == str(context.exception))
631+
632+
633+
class TestInvalidEpisodeDates(unittest.TestCase):
634+
def setUp(self):
635+
test_dir = os.path.dirname(__file__)
636+
test_feeds_dir = os.path.join(test_dir, "test_feeds")
637+
invalid_episode_path = os.path.join(test_feeds_dir, "invalid_episode_dates.rss")
638+
with open(invalid_episode_path, "rb") as invalid_episode_file:
639+
self.invalid_episode = invalid_episode_file.read()
640+
641+
def test_invalid_episode_dates(self):
642+
with self.assertRaises(Podcast.InvalidPodcastFeed) as context:
643+
Podcast.Podcast(self.invalid_episode)
644+
self.assertTrue('Invalid Podcast Feed, show level pubDate: "Mon, 24 Mar 2008 23:30:07 GMT", could not be parsed' == str(context.exception))
645+
646+
647+
619648
if __name__ == "__main__":
620649
unittest.main()

0 commit comments

Comments
 (0)