Skip to content

Add some simple test cases #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apply/tests.py
Original file line number Diff line number Diff line change
@@ -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)