Ejemplo n.º 1
0
    def test_direct_all(self):
        start_date = datetime.date(year=2017, month=1, day=1)
        end_date = datetime.date(year=2017, month=1, day=5)
        direct(start_date='2017/01/01', end_date='2017/01/5', format='%Y/%m/%d')

        qs = DailyTran.objects.filter(date__range=(start_date, end_date))
        self.assertEqual(qs.count(), 4*5)
Ejemplo n.º 2
0
    def test_direct_format(self):
        direct(start_date=self.start_date, end_date=self.end_date)
        obj = Goose.objects.filter(code='肉鵝(上鵝)價格/土鵝').first()

        qs = DailyTran.objects.filter(product=obj,
                                      date__range=(self.start_date, self.end_date))
        self.assertEqual(qs.count(), 3)
Ejemplo n.º 3
0
    def test_direct_multi(self):
        start_date = datetime.date(year=2017, month=1, day=1)
        end_date = datetime.date(year=2017, month=1, day=10)
        direct(start_date='2017/01/01', end_date='2017/01/10', format='%Y/%m/%d')
        obj_ids = Goose.objects.filter(Q(code='肉鵝(上鵝)價格/土鵝') | Q(code='小鵝產地價格(隻)/土鵝')).values('id')

        qs = DailyTran.objects.filter(product__id__in=obj_ids,
                                      date__range=(start_date, end_date))
        self.assertEqual(qs.count(), 2*10)