def test_raises_KeyError_when_feed_is_not_registered (self): library = FeedLibrary() record = Mock() record.feed_type = 'nonexistent' with self.assertRaises(KeyError): library.get_feed(record)
def test_causes_the_same_feed_record_to_be_returned_on_different_calls_to_getRecord (self): library = FeedLibrary(shared=False) library.register(ListItemFeed, 'li') feed = ListItemFeed('[1, 2, 3]') record = library.get_record(feed) self.assertIs(record, library.get_record(feed))
def test_doesnt_return_the_same_feed_from_different_libraries (self): library1 = FeedLibrary(shared=False) library1.register(ListItemFeed, 'li') library2 = FeedLibrary(shared=False) library2.register(ListItemFeed, 'li') feed = ListItemFeed('[1, 2, 3]') record = library1.get_record(feed) self.assertIsNot(feed, library2.get_feed(record))
def setUp(self): class DoNothinView (object): def get_context_data(self, **kwargs): # This is just so that SingleSubscriptionMixin.get_context_data # super has something to call. return {} library = FeedLibrary(shared=False) library.register(ListItemFeed, 'my list item feed') class SubscriptionView (SingleSubscriptionMixin, DoNothinView): def get_content_feed_library(self): return library def get_content_feed(self): return ListItemFeed('[1,2,3]') self.view = SubscriptionView() self.view.request = Mock() self.view.feed_data = FeedReader