From bab6e73564e80bf3e0f4a76c6b8367515d7031c7 Mon Sep 17 00:00:00 2001 From: Lorenzo Martinico Date: Sun, 24 Sep 2023 19:52:27 +0100 Subject: [PATCH] Add some simple test cases Begins to add a simple unit test suite to the app (testing one of the changes in #9f917a). --- apply/tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apply/tests.py b/apply/tests.py index 7ce503c..c0d4bc8 100644 --- a/apply/tests.py +++ b/apply/tests.py @@ -1,3 +1,26 @@ +import datetime +from django.utils import timezone +from django.utils.crypto import get_random_string from django.test import TestCase # Create your tests here. +from .models import ApplicationSession, ApplicationQuestion + +class ApplicationSessionTests(TestCase): + def test_is_today_application_open(self): + startdate = timezone.now() + enddate = timezone.now() + datetime.timedelta(days=30) + session = ApplicationSession(move_in_date=enddate, open_time=startdate, close_time=enddate,voting_open_time=enddate,voting_close_time=enddate) + self.assertIs(session.is_applying_open(),True) + + +class ApplicationQuestionTests(TestCase): + + def test_is_question_correct_length(self): + startdate = timezone.now() + enddate = timezone.now() + datetime.timedelta(days=30) + session = ApplicationSession(move_in_date=enddate, open_time=startdate, close_time=enddate,voting_open_time=enddate,voting_close_time=enddate) + long_enough_title = get_random_string(500) + long_enough_question = ApplicationQuestion(session=session,question_text=long_enough_title) + self.assertEqual(len(long_enough_question.question_text),500) +