Project_Camper/vagus/reservation/tests.py
2021-01-30 22:43:49 +01:00

34 lines
1.3 KiB
Python
Executable File

from django.test import TestCase
from .models import Reservation
import datetime
from django.utils import timezone
from camper.models import Offer,Offer_Category
from users.models import Base_User
# Create your tests here.
class ReservationCreate(TestCase):
def setUp(self):
testauthor = Base_User.objects.create(email ='test2@vagus.pl', password = '13test45')
testoffer = Offer.objects.create(title = 'tytul',created_by = testauthor,price = 23, category = Offer_Category.objects.get(name = 'CamperVan'))
def test_correct_date(self):
today= datetime.date.today()
ed = datetime.date(year=2021, month=1, day=20)
Reservation.objects.create(
user = Base_User.objects.get(email = 'test2@vagus.pl'),
offer = Offer.objects.get(id = 16),
reservation_start_date = today,
reservation_end_date = ed,
)
def test_incorret_date(self):
today = datetime.date.today()
ed = datetime.date(year = 2020, month=5, day = 15)
Reservation.objects.create(
user = Base_User.objects.get(email = 'test2@vagus.pl'),
offer = Offer.objects.get(id = 16),
reservation_start_date = today,
reservation_end_date = ed,
)