Exemple #1
0
 def test_counter_repr(self):
     one_hour_ago = datetime.now() - timedelta(hours=1)
     date_str = time.asctime(one_hour_ago.timetuple())
     count = object()
     c = CounterRecord(count=count, date=date_str)
     c.age_count(0)
     self.assertEqual(c.__repr__(),
                      'CountRecord <{} - {}>'.format(0, date_str))
Exemple #2
0
 def test_age_count_older(self):
     """
     Initialize a CounterRecord to one hour ago, then reset the count by passing 0
     to age_count (i.e. "reset if the stored date is older than now")
     """
     one_hour_ago = datetime.now() - timedelta(hours=1)
     date_str = time.asctime(one_hour_ago.timetuple())
     count = object()
     c = CounterRecord(count=count, date=date_str)
     c.age_count(0)
     self.assertEqual(c.get_count(), 0)
Exemple #3
0
 def test_age_count_older(self):
     """
     Initialize a CounterRecord to one hour ago, then reset the count by passing 0
     to age_count (i.e. "reset if the stored date is older than now")
     """
     one_hour_ago = datetime.now() - timedelta(hours=1)
     date_str = time.asctime(one_hour_ago.timetuple())
     count = object()
     c = CounterRecord(count=count, date=date_str)
     c.age_count(0)
     self.assertEqual(c.get_count(), 0)
Exemple #4
0
 def test_age_count_newer(self):
     """
     Initialize a CounterRecord to one hour ago, then call age_count with 2 hours
     to verify that the count won't reset. ("Reset if the stored date is older than
     2 hours ago")
     """
     one_hour_ago = datetime.now() - timedelta(hours=1)
     date_str = time.asctime(one_hour_ago.timetuple())
     count = object()
     c = CounterRecord(count=count, date=date_str)
     c.age_count(2 * 60 * 60)
     self.assertEqual(c.get_count(), count)
Exemple #5
0
 def test_age_count_newer(self):
     """
     Initialize a CounterRecord to one hour ago, then call age_count with 2 hours
     to verify that the count won't reset. ("Reset if the stored date is older than
     2 hours ago")
     """
     one_hour_ago = datetime.now() - timedelta(hours=1)
     date_str = time.asctime(one_hour_ago.timetuple())
     count = object()
     c = CounterRecord(count=count, date=date_str)
     c.age_count(2 * 60 * 60)
     self.assertEqual(c.get_count(), count)