Ejemplo n.º 1
0
def top(limit=10, offset=0, game=None, period=Period.WEEK):
    q = Qry('videos/top')
    q.add_param(keys.LIMIT, limit, 10)
    q.add_param(keys.OFFSET, offset, 0)
    q.add_param(keys.GAME, game)
    q.add_param(keys.PERIOD, Period.validate(period), Period.WEEK)
    return q
Ejemplo n.º 2
0
def get_top(limit=10, offset=0, game=None, period=Period.WEEK, broadcast_type=BroadcastType.HIGHLIGHT):
    q = Qry('videos/top', use_token=False)
    q.add_param(keys.LIMIT, limit, 10)
    q.add_param(keys.OFFSET, offset, 0)
    q.add_param(keys.GAME, game)
    q.add_param(keys.PERIOD, Period.validate(period), Period.WEEK)
    q.add_param(keys.BROADCAST_TYPE, BroadcastType.validate(broadcast_type))
    return q
    def test_period(self):
        Period.validate(Period.WEEK)
        Period.validate(Period.MONTH)
        Period.validate(Period.ALL)
        Period.validate('week')
        Period.validate('month')
        Period.validate('all')

        with self.assertRaises(ValueError):
            Period.validate(0)
        with self.assertRaises(ValueError):
            Period.validate(-1)
        with self.assertRaises(ValueError):
            Period.validate('')
        with self.assertRaises(ValueError):
            Period.validate('year')
        with self.assertRaises(ValueError):
            Period.validate(9.4124)