예제 #1
0
    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))
예제 #2
0
 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()),
     }
예제 #3
0
  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)
예제 #4
0
    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)
예제 #5
0
    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")
예제 #6
0
    def test_all(self):
        leaderboard = Leaderboard(horizon="all", metric="bar", interval="baz")

        self.assertIsNone(leaderboard.start_date())
예제 #7
0
    def test_bogus(self):
        leaderboard = Leaderboard(horizon="foo", metric="bar", interval="foo")

        self.assertIsNone(leaderboard.start_date())
예제 #8
0
    def test_default(self):
        leaderboard = Leaderboard(horizon="foo", metric="bar", interval="baz")

        self.assertEqual(str(leaderboard), "foo.bar.baz")
예제 #9
0
  def test_all(self):
    leaderboard = Leaderboard(horizon="all", metric="bar", interval="baz")

    self.assertIsNone(leaderboard.start_date())
예제 #10
0
  def test_bogus(self):
    leaderboard = Leaderboard(horizon="foo", metric="bar", interval="foo")

    self.assertIsNone(leaderboard.start_date())
예제 #11
0
 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()),
     }