示例#1
0
def show_reddit_tournaments(game):
    streams = [{'label': 'STREAM %s' % stream,
                'path': plugin.url_for('twitch_play_stream', stream=stream),
                'is_playable': True
               }
               for stream in games[game].get('twitch_streams', {'EN': []})['EN']]
    events = reddit.build_tournaments(plugin, game, games[game]['subreddit'])
    streams.extend(events)
    return streams
    def test_builds_tournaments(self, reddit_mock):
        sticky_mock = mock.Mock()
        sticky_mock.id = '123'
        sticky_mock.title = 'Recent Tournament'

        normal_mock = mock.Mock()
        normal_mock.id = '456'
        normal_mock.title = 'Old Tournament'

        client_mock = reddit_mock.return_value
        client_mock.get_subreddit.return_value.get_sticky.return_value = sticky_mock
        client_mock.get_subreddit.return_value.get_new.return_value = [normal_mock]


        from addon import plugin
        from resources.lib import reddit
        tournaments = reddit.build_tournaments(plugin, 'Hyped eSport', 'hypedvods')

        expected = [{'label': 'Recent Tournament',
                     'path': 'plugin://plugin.video.eventvods/tournament/Hyped+eSport/reddit/123/match'},
                    {'label': 'Old Tournament',
                     'path': 'plugin://plugin.video.eventvods/tournament/Hyped+eSport/reddit/456/match'}
                   ]
        assert_equals(expected, tournaments)