Exemplo n.º 1
0
    def test_after(self):
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        now = datetime.datetime.now()

        u = User.objects.create_user('u', '*****@*****.**')
        u.date_joined = today
        u.save()
        
        qs = User.objects.all()
        qss = QuerySetStats(qs, 'date_joined')

        self.assertEqual(qss.after(today), 1)
        self.assertEqual(qss.after(now), 0)
        u.date_joined=tomorrow
        u.save()
        self.assertEqual(qss.after(now), 1)
Exemplo n.º 2
0
    def test_after(self):
        now = compat.now()
        today = _remove_time(now)
        tomorrow = today + datetime.timedelta(days=1)

        u = User.objects.create_user('u', '*****@*****.**')
        u.date_joined = today
        u.save()

        qs = User.objects.all()
        qss = QuerySetStats(qs, 'date_joined')

        self.assertEqual(qss.after(today)[0], 1)
        self.assertEqual(qss.after(now)[0], 0)
        u.date_joined = tomorrow
        u.save()
        self.assertEqual(qss.after(now)[0], 1)