-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed_test.py
36 lines (27 loc) · 966 Bytes
/
feed_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
"Test the basic import of feeds"
import feed_logger
def test_file_loading():
"""Test the basic load_feeds.
Should return a generator of valid, stripped urls"""
filename = "feeds.lst"
feeds = list(feed_logger.load_feeds(filename))
print len(feeds)
assert len(feeds) == 8
assert feeds[1] == "http://lwn.net/headlines/newrss"
def test_feed_loading():
"Test that the entries of a url are correctly loaded"
url = "examplefeed.rss"
data = list(feed_logger.entries_for_feed(url))
print len(data)
assert len(data) == 40
class CountingHandler():
"Simple stub for a function. Counts how often it's called"
def __init__(self):
self.count = 0
def __call__(self, *args, **kwargs):
self.count += 1
def test_main():
"Test that the main method of feed_logger works"
stub_handler = CountingHandler()
feed_logger.simple_main("test.lst", stub_handler)
assert stub_handler.count == 40