import unittest
from datetime import datetime, timedelta
from uw.local.teaching.webui.accommodation import *
[docs]class AccomodationTests (unittest.TestCase):
[docs] def setUp (self):
""" Set up method that runs before each test case.
"""
pass
[docs] def test_parse_class_id_invalid_class (self):
""" Tests if parse_class_id () functions as expected when given an
invalid class id.
"""
errors = []
self.assertIsNone (parse_class_id (None, [], errors, 'not an int',
'1', 'ECE', 240))
self.assertEqual (errors, ["Invalid class number"])
[docs] def test_parse_class_id_invalid_section (self):
""" Tests if parse_class_id () functions as expected when given an
invalid section code.
"""
errors = []
self.assertIsNone (parse_class_id (None, [], errors, '1',
240, 'ECE', 'not an int'))
self.assertEqual (errors, ["Invalid section number"])
[docs] def test_parse_class_id_both_invalid (self):
""" Tests if parse_class_id () functions as expected when given an
invalid section code and class id.
"""
errors = []
self.assertIsNone (parse_class_id (None, [], errors, 'not an int', 240, 'ECE', 'not an int'))
self.assertEqual (errors, ["Invalid class number"])
[docs] def test_parse_class_id_nonexistent_class (self):
""" TODO: Tests parse_class_id () given a nonexistent class section.
"""
pass
[docs] def test_parse_class_id_no_errors (self):
""" TODO: Tests parse_class_id () given inputs that shouldn't hit any
of the error checks.
"""
pass
[docs] def test_parse_start_time_invalid_exam_date (self):
"""Tests parse_start_time () given an invalid exam date
"""
errors = []
result = {}
self.assertIsNone (parse_start_time (None, result, errors,
'invalid date string', '12:30 PM'))
self.assertEqual (result, {})
self.assertEqual (errors, ['Invalid assessment date'])
[docs] def test_parse_start_time_invalid_start_time (self):
"""Tests parse_start_time () given an invalid start time
"""
errors = []
result = {}
self.assertIsNone (parse_start_time (None, result, errors,
'01/01/2018', 'invalid time string'))
self.assertEqual (result, {})
self.assertEqual (errors, ['Invalid assessment time'])
[docs] def test_parse_duration_invalid_value (self):
"""Tests parse_duration () given an invalid value
"""
errors = []
result = {}
self.assertIsNone (parse_duration (None, result, errors, 'not an int'))
self.assertEqual (result, {})
self.assertEqual (errors, ['Invalid duration'])
def test_parse_extra_input_is_none (self):
"""Tests parse_extra given a NoneType input.
"""
self.assertEqual (parse_extra (None), {'extra_candidate': False})