Map space bar to scroll_unread_items (thanks estar).
[straw.git] / test / test_feeds.py
blobc7c9fce57e32b1f282e4803940af419936d6dae8
2 import pygtk
3 import gobject
4 from mock import Mock
5 import nose
7 import os
9 from straw.feeds import FifoCache
11 """
12 class TestSubscription:
14 def cb(self, *args):
15 ''' default callback that asserts that it's been called'''
16 assert True # callback called
18 def setUp(self):
19 ''' setup subscription testing '''
20 self.subscription = Subscription()
22 def tearDown(self):
23 ''' tear down tests '''
24 self.subscription = None
26 def test_add_feed_into_default_category(self):
27 ''' Test adding of a feed subscription '''
28 feed = Feed('Test Feed','http://test.com/feed')
29 self.subscription.connect('feed-added',self.cb)
30 self.subscription.add(feed, category=None)
31 assert feed in self.subscription.feeds # XXX why? assuming that subscription is a 'feed list'?
33 def test_get_feed_without_category(self):
34 ''' Test retrieving a feed that is not part of any category '''
35 feed = Feed('TestFeed','http://test.com/feed')
36 feed.id = 255
37 self.subscription.add(feed, category=None)
38 f = self.subscription.get('http://test.com/feed')
39 assert f == feed
41 def test_get_feed_with_category(self):
42 ''' Test retrieving a feed that is part of a category '''
43 feed = Feed('TestFeed','http://test.com/feed')
44 feed.id = 255
45 category = self.subscription.get_category('CategoryPlanet')
46 self.subscription.add(feed, category=category)
47 f = self.subscription.get('http://test.com/feed')
48 assert f == feed
50 def test_add_category_empty(self):
51 ''' Add an empty category, a category with no attached feeds '''
52 category = Category('Empty Category')
53 self.subscription.connect('category-added', self.cb)
54 self.subscription.add_category(category) ## XXX add_foo sucky API?
55 assert category in self.subscription.categories
57 #def test_add_category_with_feeds(self):
58 # ''' i.e., most likely an OPML subscription '''
59 # pass
61 def test_get_category(self):
62 ''' Test category retrieval '''
63 catA = Category('NewCategory')
64 self.subscription.add_category(catA)
65 catB = self.subscription.get_category('NewCategory')
66 assert catA == catB
68 def test_add_feed_in_category(self):
69 ''' test adding a feed that will be part of a new category '''
70 def _cb(category, feed):
71 assert feed in category
72 feed = Feed('Test Feed', 'http://test.com/feed')
73 category = self.subscription.get_category('CategoryPlanet')
74 self.subscription.connect('category-feed-added', _cb)
75 self.subscription.add(feed, category=category)
76 assert feed in category
77 assert feed not in self.subscription.uncategorized
79 def test_remove_feed_out_of_category(self):
80 ''' test moving a feed out of a category '''
81 feed = Feed('Test','http://test.com/feed')
82 category = Category('New')
83 self.subscription.add_category(category)
84 self.subscription.add(feed,category)
85 self.subscription.remove(feed, category)
86 assert feed not in category
87 assert feed in self.subscription.uncategorized
89 def test_remove_category_empty(self):
90 ''' test removing an empty category '''
91 category = Category('New')
92 self.subscription.add_category(category)
93 self.subscription.remove_category('New')
94 assert category not in self.subscription.categories
96 def test_remove_category_with_feeds(self):
97 ''' remove a category with feeds '''
98 category = Category('New')
101 def test_remove_feed_with_category(self):
102 ''' test removing a feed that's part of a category '''
103 pass
105 def test_remove_feed_no_category(self):
106 ''' test removing a feed that is not part of a category '''
107 pass
110 class TestFifoCache:
112 def setUp(self):
113 self.cache = FifoCache(num_entries=20)
115 def tearDown(self):
116 self.cache = None
118 def test_feed_update_info(self):
119 ''' test that updating a feed's metadata works and notifications
120 are working properly.'''
121 for i,x in enumerate(range(19)):
122 self.cache[i] = x
123 assert len(self.cache) == 19
125 def test_feed_update_items(self):
126 ''' test updating of feeds items from new items '''
127 pass
129 def test_feed_restore_items(self):
130 ''' test item restoration from an external source (e.g., database,
131 etc...)'''
132 pass
135 def test_init(self):
136 ''' Test initialization process (e.g. loading of feeds, categories,
137 and grouping/categorizing of feeds into different categories.'''
138 pass