Source code for uw.local.teaching.webui.schedule_test
import unittest
from collections import namedtuple
from freezegun import freeze_time
from uw.local.teaching.webui.schedule import *
[docs]@freeze_time ('2020-01-01')
class ScheduleTests (unittest.TestCase):
[docs] def setUp (self):
""" Setup method which runs before each test case.
"""
self.Exam = namedtuple ('Exam', 'building_code sequence_text start_time')
[docs] def test_special_sitting_building_code_is_pac (self):
""" Tests special_sitting with building code set to 'PAC'
"""
exam = self.Exam (building_code="PAC", sequence_text=None,
start_time=None)
self.assertTrue (special_sitting (exam))
[docs] def test_special_sitting_building_code_not_pac (self):
""" Tests special_sitting with building code not set to 'PAC'
"""
exam = self.Exam (building_code="NOT PAC", sequence_text=None,
start_time=None)
self.assertFalse (special_sitting (exam))
[docs] def test_include_sequence_should_return_true (self):
""" Tests include_sequence with parameters that should return True.
"""
exam = self.Exam (building_code=None, sequence_text="Not None",
start_time=datetime.datetime (2019, 1, 1))
self.assertTrue (include_sequence (exam))
[docs] def test_include_sequence_should_return_false_1 (self):
""" Tests include_sequence with parameters that should return True.
"""
exam = self.Exam (building_code=None, sequence_text=None,
start_time=datetime.datetime (2019, 1, 1))
self.assertFalse (include_sequence (exam))
[docs] def test_include_sequence_should_return_false_2 (self):
""" Tests include_sequence with parameters that should return True.
"""
exam = self.Exam (building_code=None, sequence_text="Not None",
start_time=datetime.datetime (2021, 1, 1))
self.assertFalse (include_sequence (exam))
[docs] def test_include_sequence_should_return_false_3 (self):
""" Tests include_sequence with parameters that should return True.
"""
exam = self.Exam (building_code=None, sequence_text="Not None",
start_time=None)
self.assertFalse (include_sequence (exam))