24 lines
776 B
Python
24 lines
776 B
Python
|
from django.test import TestCase
|
||
|
from przyrost.models import *
|
||
|
from django.utils import timezone
|
||
|
class testbasic(TestCase):
|
||
|
|
||
|
def setUp(self) -> None:
|
||
|
User.objects.all().delete()
|
||
|
Category.objects.all().delete()
|
||
|
Post.objects.all().delete()
|
||
|
u=User.objects.create(name="Admin")
|
||
|
c=Category.objects.create(name="test")
|
||
|
u.save()
|
||
|
c.save()
|
||
|
p=Post.objects.create(
|
||
|
created_at=timezone.datetime.now(),
|
||
|
category=c,
|
||
|
text="I nawet kiedy będę sam nie zmienię się to nie móóóój świattttt"
|
||
|
)
|
||
|
p.authors.set([u])
|
||
|
p.save()
|
||
|
def test_getPostByDate(self):
|
||
|
self.assertEqual(len(Post.objects.all()),1)
|
||
|
self.assertEqual(len(Post.getTodays()), 1)
|