Esempio n. 1
0
 def test_create_stream_object_online_nogame_nogametitle(self):
     expected = Stream("online_gametitle", True, "[]")
     with patch('urllib.request.urlopen') as mock:
         mock.return_value = MockResponse(('{"stream":{"channel":{"status":"'
                                           'Test stream status'
                                           ' with no game"}}}'
                                           ), 200)
         actual = create_stream_object("online_gametitle")
         self.assertEqual(expected.stream_name, actual.stream_name)
         self.assertEqual(expected.stream_status, actual.stream_status)
         self.assertEqual(expected.cur_playing, actual.cur_playing)
Esempio n. 2
0
 def test_create_stream_object_offline(self):
     expected = Stream("rwdalpe", False, "[]")
     with patch('urllib.request.urlopen') as mock:
         mock.return_value = MockResponse(('{"_links":{"channel":"https://ap'
                                           'i.twitch.tv/kraken/channels/rwda'
                                           'lpe","self":"https://api.twit'
                                           'ch.tv/kraken/streams/rwdalpe"},'
                                           '"stream":null}'), 
                                          200)
         actual = create_stream_object("rwdalpe")
         self.assertEqual(expected.stream_name, actual.stream_name)
         self.assertEqual(expected.stream_status, actual.stream_status)
         self.assertEqual(expected.cur_playing, actual.cur_playing)
Esempio n. 3
0
 def run(self):
     logging.debug("Stream Status Thread starting")
     reddit_wrapper = get_reddit_wrapper(self._config)
     stream_obj = None
     while (True):
         new_stream_obj = stream.create_stream_object(self._stream_name)
         if (new_stream_obj != None):
             if (stream_obj != None):
                 if (stream.should_update_sidebar(stream_obj,
                                                  new_stream_obj)):
                     stream.update_sidebar(reddit_wrapper,
                                           self._subreddit_name,
                                           new_stream_obj)
             else:
                 stream.update_sidebar(reddit_wrapper, self._subreddit_name,
                                       new_stream_obj)
             stream_obj = new_stream_obj
         time.sleep(self._update_interval)
     logging.debug("Stream status thread stopping")
Esempio n. 4
0
 def run(self):
     logging.debug("Stream Status Thread starting")
     reddit_wrapper = get_reddit_wrapper(self._config)
     stream_obj = None
     while (True):
         new_stream_obj = stream.create_stream_object(self._stream_name)
         if (new_stream_obj != None):
             if (stream_obj != None):
                 if (stream.should_update_sidebar(stream_obj,
                                                  new_stream_obj)):
                     stream.update_sidebar(reddit_wrapper,
                                           self._subreddit_name,
                                           new_stream_obj)
             else:
                 stream.update_sidebar(reddit_wrapper, self._subreddit_name,
                                       new_stream_obj)
             stream_obj = new_stream_obj
         time.sleep(self._update_interval)
     logging.debug("Stream status thread stopping")