Exemple #1
0
 def test_n_days_ago(self):
     """Test the n_days_ago method."""
     delta_day = datetime.timedelta(days=1)
     today = timezone.now().replace(microsecond=0,
                                    second=0,
                                    minute=0,
                                    hour=0)
     two_days_ago = (today - delta_day) - delta_day
     self.assertEqual(two_days_ago, ReportQueryHandler.n_days_ago(today, 2))
Exemple #2
0
 def test_get_time_frame_filter_last_thirty(self):
     """Test _get_time_frame_filter for last thirty days."""
     query_params = {
         'filter': {
             'resolution': 'daily',
             'time_scope_value': -30,
             'time_scope_units': 'day'
         }
     }
     handler = ReportQueryHandler(query_params, '', self.tenant,
                                  'unblended_cost', 'currency_code')
     current_day = timezone.now().replace(microsecond=0, second=0, minute=0)
     ten_days_ago = ReportQueryHandler.n_days_ago(current_day, 30)
     start = handler.start_datetime
     end = handler.end_datetime
     interval = handler.time_interval
     self.assertEqual(start, ten_days_ago)
     self.assertEqual(end, current_day)
     self.assertIsInstance(interval, list)
     self.assertTrue(len(interval) == 31)