コード例 #1
0
 def test_all_results_are_datetimes(self):
     "Test every object returned is a datetime object"
     a_week_ago = dt.now() - timedelta(days=7)
     today = dt.now()
     dt_list = logic.dates_in_range(a_week_ago, today, entry_count=14)
     for dto in dt_list:
         self.assertTrue(isinstance(dto, datetime))
コード例 #2
0
 def test_mixed_dates(self):
     "Test that dates in reversed order (ends before it starts) result in correct list of dates"
     start_dt = dt.wtz(datetime(year=2000, month=02, day=01))
     end_dt = start_dt + timedelta(days=14)
     dt_list = logic.dates_in_range(end_dt, start_dt, 14) # mixed order of start and end here
     self.assertEqual(len(dt_list), 14)
     self.assertTrue(dt_list[0] >= start_dt)
     self.assertTrue(dt_list[-1] <= end_dt)
コード例 #3
0
 def test_custom_case(self):
     "Test a call with custom parameters works as expected"
     start_dt = dt.wtz(datetime(year=2000, month=02, day=01))
     end_dt = start_dt + timedelta(days=14)
     dt_list = logic.dates_in_range(start_dt, end_dt, 14)
     self.assertEqual(len(dt_list), 14)
     self.assertTrue(dt_list[0] >= start_dt)
     self.assertTrue(dt_list[-1] <= end_dt)
コード例 #4
0
 def test_list_dates_within_range(self):
     "Test that the dates in the range are within the given bounds"
     a_week_ago = dt.now() - timedelta(days=7)
     today = dt.now()
     dt_list = logic.dates_in_range(a_week_ago, today, entry_count=14)
     for dto in dt_list:
         print today
         print dto
         print a_week_ago
         print
         self.assertTrue(dto >= a_week_ago)
         self.assertTrue(dto <= today)
コード例 #5
0
 def test_negative_count(self):
     "Test that calling the function with a negative count results in a list with zero elements"
     start_dt = dt.wtz(datetime(year=2000, month=02, day=01))
     end_dt = start_dt + timedelta(days=14)
     dt_list = logic.dates_in_range(end_dt, start_dt, -14)
     self.assertEqual(len(dt_list), 0)
コード例 #6
0
 def test_mixed_dates_datetimes(self):
     "Test that if a date object is passed in, then all resulting objects will be datetime objects."
     start_dt = date.today()
     end_dt = dt.now() - timedelta(days=14)
     dt_list = logic.dates_in_range(start_dt, end_dt, 14)
     [self.assertTrue(isinstance(dto, datetime)) for dto in dt_list]
コード例 #7
0
 def test_standard_case(self):
     "Test a standard use case with 14 dates spanning the last week"
     today = dt.now()
     a_week_ago = today - timedelta(days=7)
     dt_list = logic.dates_in_range(a_week_ago, today, entry_count=14)
     self.assertEqual(len(dt_list), 14)