def test_default(self): leaderboard1 = Leaderboard(horizon="foo", metric="bar", interval="baz") leaderboard2 = Leaderboard(horizon="foo", metric="bar", interval="baz") leaderboard3 = Leaderboard(horizon="baz", metric="bar", interval="foo") self.assertTrue(hash(leaderboard1) == hash(leaderboard2)) self.assertFalse(hash(leaderboard1) == hash(leaderboard3))
def channel(self, channel): return { 'channel': channel, 'all': self._channel(self._collections['all'], channel), 'monthly': self._channel(self._collections['monthly'], channel, Leaderboard('monthly', None, None).start_date()), 'daily': self._channel(self._collections['daily'], channel, Leaderboard('daily', None, None).start_date()), }
def test_daily(self): leaderboard = Leaderboard(horizon="daily", metric="bar", interval="baz") date = leaderboard.start_date() now = datetime.datetime.now(datetime.timezone.utc) self.assertEqual(now.day, date.day) self.assertEqual(0, date.hour) self.assertEqual(0, date.minute)
def test_default(self): leaderboard = Leaderboard(horizon="foo", metric="bar", interval="baz") self.assertEqual(leaderboard.horizon, "foo") self.assertEqual(leaderboard.metric, "bar") self.assertEqual(leaderboard.interval, "baz")
def test_all(self): leaderboard = Leaderboard(horizon="all", metric="bar", interval="baz") self.assertIsNone(leaderboard.start_date())
def test_bogus(self): leaderboard = Leaderboard(horizon="foo", metric="bar", interval="foo") self.assertIsNone(leaderboard.start_date())
def test_default(self): leaderboard = Leaderboard(horizon="foo", metric="bar", interval="baz") self.assertEqual(str(leaderboard), "foo.bar.baz")
def status(self): return { 'all': self._status(self._collections['all']), 'monthly': self._status(self._collections['monthly'], Leaderboard('monthly', None, None).start_date()), 'daily': self._status(self._collections['daily'], Leaderboard('daily', None, None).start_date()), }