9 from straw
.feeds
import Feed
11 class TestSubscription:
14 ''' default callback that asserts that it's been called'''
15 assert True # callback called
18 ''' setup subscription testing '''
19 self.subscription = Subscription()
22 ''' tear down tests '''
23 self.subscription = None
25 def test_add_feed_into_default_category(self):
26 ''' Test adding of a feed subscription '''
27 feed = Feed('Test Feed','http://test.com/feed')
28 self.subscription.connect('feed-added',self.cb)
29 self.subscription.add(feed, category=None)
30 assert feed in self.subscription.feeds # XXX why? assuming that subscription is a 'feed list'?
32 def test_get_feed_without_category(self):
33 ''' Test retrieving a feed that is not part of any category '''
34 feed = Feed('TestFeed','http://test.com/feed')
36 self.subscription.add(feed, category=None)
37 f = self.subscription.get('http://test.com/feed')
40 def test_get_feed_with_category(self):
41 ''' Test retrieving a feed that is part of a category '''
42 feed = Feed('TestFeed','http://test.com/feed')
44 category = self.subscription.get_category('CategoryPlanet')
45 self.subscription.add(feed, category=category)
46 f = self.subscription.get('http://test.com/feed')
49 def test_add_category_empty(self):
50 ''' Add an empty category, a category with no attached feeds '''
51 category = Category('Empty Category')
52 self.subscription.connect('category-added', self.cb)
53 self.subscription.add_category(category) ## XXX add_foo sucky API?
54 assert category in self.subscription.categories
56 #def test_add_category_with_feeds(self):
57 # ''' i.e., most likely an OPML subscription '''
60 def test_get_category(self):
61 ''' Test category retrieval '''
62 catA = Category('NewCategory')
63 self.subscription.add_category(catA)
64 catB = self.subscription.get_category('NewCategory')
67 def test_add_feed_in_category(self):
68 ''' test adding a feed that will be part of a new category '''
69 def _cb(category, feed):
70 assert feed in category
71 feed = Feed('Test Feed', 'http://test.com/feed')
72 category = self.subscription.get_category('CategoryPlanet')
73 self.subscription.connect('category-feed-added', _cb)
74 self.subscription.add(feed, category=category)
75 assert feed in category
76 assert feed not in self.subscription.uncategorized
78 def test_remove_feed_out_of_category(self):
79 ''' test moving a feed out of a category '''
80 feed = Feed('Test','http://test.com/feed')
81 category = Category('New')
82 self.subscription.add_category(category)
83 self.subscription.add(feed,category)
84 self.subscription.remove(feed, category)
85 assert feed not in category
86 assert feed in self.subscription.uncategorized
88 def test_remove_category_empty(self):
89 ''' test removing an empty category '''
90 category = Category('New')
91 self.subscription.add_category(category)
92 self.subscription.remove_category('New')
93 assert category not in self.subscription.categories
95 def test_remove_category_with_feeds(self):
96 ''' remove a category with feeds '''
97 category = Category('New')
100 def test_remove_feed_with_category(self):
101 ''' test removing a feed that's part of a category '''
104 def test_remove_feed_no_category(self):
105 ''' test removing a feed that is not part of a category '''
112 self
.feed
= FeedAdapter()
117 def test_feed_update_info(self
):
118 ''' test that updating a feed's metadata works and notifications
119 are working properly.'''
122 def test_feed_update_items(self
):
123 ''' test updating of feeds items from new items '''
126 def test_feed_restore_items(self
):
127 ''' test item restoration from an external source (e.g., database,
133 ''' Test initialization process (e.g. loading of feeds, categories,
134 and grouping/categorizing of feeds into different categories.'''