def setUp(self): TrackerTest.setUp(self) self.guide1 = ChannelGuide(u'http://example.com/') self.store1 = ChannelGuide(u'http://amazon.com/') self.store1.store = ChannelGuide.STORE_VISIBLE self.store1.signal_change() self.store2 = ChannelGuide(u'http://not-amazon.com/') self.store2.store = ChannelGuide.STORE_INVISIBLE self.store2.signal_change() messages.TrackGuides().send_to_backend() self.runUrgentCalls()
def test_stop(self): self.check_message_count(2) # GuideList, StoreList messages.StopTrackingGuides().send_to_backend() self.runUrgentCalls() self.guide.set_title(u"Booya") ChannelGuide(u'http://example.com/3') self.guide1.remove() self.check_message_count(2)
def setUp(self): EventLoopTest.setUp(self) Feed(u'dtv:search') self.test_handler = TestFrontendMessageHandler() messages.FrontendMessage.install_handler(self.test_handler) self.backend_message_handler = messagehandler.BackendMessageHandler( None) messages.BackendMessage.install_handler(self.backend_message_handler) self.channelTabOrder = TabOrder(u'channel') self.playlistTabOrder = TabOrder(u'playlist') # Adding a guide ensures that if we remove all our # channel/playlist tabs the selection code won't go crazy. self.guide = ChannelGuide(app.config.get(prefs.CHANNEL_GUIDE_URL))
class GuideTrackTest(TrackerTest): def setUp(self): TrackerTest.setUp(self) self.guide1 = ChannelGuide(u'http://example.com/') messages.TrackGuides().send_to_backend() self.runUrgentCalls() def check_info(self, guideInfo, guide): self.assertEquals(guideInfo.name, guide.get_title()) self.assertEquals(guideInfo.id, guide.id) self.assertEquals(guideInfo.url, guide.get_url()) self.assertEquals(guideInfo.default, guide.is_default()) def test_initial_list(self): self.assertEquals(len(self.test_handler.messages), 1) message = self.test_handler.messages[0] self.assert_(isinstance(message, messages.GuideList)) self.check_info(message.default_guide, self.guide) self.check_info_list(message.added_guides, [self.guide1]) def check_changed_message_type(self, message): self.assertEquals(type(message), messages.TabsChanged) self.assertEquals(message.type, 'guide') def test_added(self): g = ChannelGuide(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, added=[g]) @uses_httpclient def test_removed(self): self.guide1.remove() self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, removed=[self.guide1]) def test_change(self): self.guide1.set_title(u"Booya") self.runUrgentCalls() self.check_message_count(2) self.check_changed_message(1, changed=[self.guide1]) @uses_httpclient def test_stop(self): self.check_message_count(1) messages.StopTrackingGuides().send_to_backend() self.runUrgentCalls() self.guide.set_title(u"Booya") g = ChannelGuide(u'http://example.com/3') self.guide1.remove() self.check_message_count(1)
def test_added(self): g = ChannelGuide(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(3) # GuideList, StoreList self.check_changed_message(2, added=[g])
class GuideTrackTest(TrackerTest): def setUp(self): TrackerTest.setUp(self) self.guide1 = ChannelGuide(u'http://example.com/') self.store1 = ChannelGuide(u'http://amazon.com/') self.store1.store = ChannelGuide.STORE_VISIBLE self.store1.signal_change() self.store2 = ChannelGuide(u'http://not-amazon.com/') self.store2.store = ChannelGuide.STORE_INVISIBLE self.store2.signal_change() messages.TrackGuides().send_to_backend() self.runUrgentCalls() def check_info(self, guideInfo, guide): self.assertEquals(guideInfo.name, guide.get_title()) self.assertEquals(guideInfo.id, guide.id) self.assertEquals(guideInfo.url, guide.get_url()) self.assertEquals(guideInfo.default, guide.is_default()) def test_initial_list(self): self.assertEquals(len(self.test_handler.messages), 2) guides, stores = self.test_handler.messages self.assert_(isinstance(guides, messages.GuideList)) self.check_info(guides.default_guide, self.guide) self.check_info_list(guides.added_guides, [self.guide1]) self.assert_(isinstance(stores, messages.StoreList)) self.check_info_list(stores.visible_stores, [self.store1]) self.check_info_list(stores.hidden_stores, [self.store2]) def check_changed_message_type(self, message, type_='site'): self.assertEquals(type(message), messages.TabsChanged) self.assertEquals(message.type, type_) def check_stores_changed_message(self, index, added=None, changed=None, removed=None): message = self.test_handler.messages[index] self.assertEquals(type(message), messages.StoresChanged) if added: self.assertEquals(len(added), len(message.added)) for obj, info in zip(added, message.added): self.check_info(info, obj) else: self.assertEquals(len(message.added), 0) if changed: self.assertEquals(len(changed), len(message.changed)) def find_changed_info(obj): for info in message.changed: if info.id == obj.id: return info for obj in changed: self.check_info(find_changed_info(obj), obj) else: self.assertEquals(len(message.changed), 0) if removed: self.assertSameSet([c.id for c in removed], message.removed) else: self.assertEquals(len(message.removed), 0) def test_added(self): g = ChannelGuide(u'http://example.com/3') self.runUrgentCalls() self.check_message_count(3) # GuideList, StoreList self.check_changed_message(2, added=[g]) @uses_httpclient def test_removed(self): self.guide1.remove() self.runUrgentCalls() self.check_message_count(3) # GuideList, StoreList, TabsChanged self.check_changed_message(2, removed=[self.guide1]) def test_change(self): self.guide1.set_title(u"Booya") self.runUrgentCalls() self.check_message_count(3) # GuideList, StoreList, TabsChanged self.check_changed_message(2, changed=[self.guide1]) def test_change_invisible(self): self.store1.store = ChannelGuide.STORE_INVISIBLE self.store1.signal_change() self.runUrgentCalls() # GuideList, StoreList, StoresChanged, TabsChanged self.check_message_count(4) self.check_stores_changed_message(2, removed=[self.store1]) self.check_changed_message(3, removed=[self.store1], type_='store') def test_change_visible(self): self.store2.store = self.guide1.STORE_VISIBLE self.store2.signal_change() self.runUrgentCalls() # GuideList, StoreList, StoresChanged, TabsChanged self.check_message_count(4) self.check_stores_changed_message(2, added=[self.store2]) self.check_changed_message(3, added=[self.store2], type_='store') @uses_httpclient def test_stop(self): self.check_message_count(2) # GuideList, StoreList messages.StopTrackingGuides().send_to_backend() self.runUrgentCalls() self.guide.set_title(u"Booya") ChannelGuide(u'http://example.com/3') self.guide1.remove() self.check_message_count(2)
def setUp(self): TrackerTest.setUp(self) self.guide1 = ChannelGuide(u'http://example.com/') messages.TrackGuides().send_to_backend() self.runUrgentCalls()