Exemplo 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(), 8*5)
Exemplo n.º 2
0
    def test_direct_format(self):
        direct(start_date=self.start_date, end_date=self.end_date)
        obj = Chicken.objects.filter(code='紅羽土雞北區').first()

        qs = DailyTran.objects.filter(product=obj,
                                      date__range=(self.start_date, self.end_date))
        self.assertEqual(qs.count(), 8)
Exemplo 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 = Chicken.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(), 20)