Beispiel #1
0
 def setUpClass(cls):
     start = date(2014, 1, 1)
     end = date(2014, 1, 31)
     cls.all_days_of_january = list(daterange(start, end))
     end = date(2014, 1, 30)
     cls.some_days_of_january = list(daterange(start, end))
     cls.missing_days_of_january = [date(2014, 1, 31)]
     cls.today = date.today()
Beispiel #2
0
    def createTestMetrics(cls, metric_class):
        parameters = {'container': 1}

        if issubclass(metric_class, ContainerMetric):
            pass
        elif issubclass(metric_class, DomainMetric):
            parameters['domain'] = 1
        else:
            raise TypeError('Cannot handle {class_name} class'.format(
                class_name=metric_class.__name__))

        start = date(2010, 1, 1)
        end = date(2010, 12, 31)

        cls.test_metrics = []

        for day in daterange(start, end):
            json = []
            for i in xrange(5):
                json.append([random.randint(1, 100), random.randint(1, 100)])
            parameters['day'] = day.day
            parameters['month'] = day.month
            parameters['year'] = day.year
            parameters['json'] = json
            test_metric = metric_class(**parameters)
            test_metric.save()
            cls.test_metrics.append(test_metric)
Beispiel #3
0
 def test_all_days_handles_current_year(self):
     results = all_days_of(date.today().year)
     first_of_year = date(self.today.year, 1, 1)
     all_days_of_the_year_untill_today = list(daterange(first_of_year, self.today))
     self.assertEqual(results, all_days_of_the_year_untill_today)
Beispiel #4
0
 def test_all_days_handles_current_month(self):
     results = all_days_of(date.today().year, self.today.month)
     first_of_month = date(self.today.year, self.today.month, 1)
     all_days_of_the_month_untill_today = list(daterange(first_of_month, self.today))
     self.assertEqual(results, all_days_of_the_month_untill_today)