Source code for uw.local.teaching.webui.grades_test

import unittest

import re

from uw.local.teaching.webui.grades import *

[docs]class GradesTest (unittest.TestCase):
[docs] def setUp (self): """ Setup method which runs before each test case. """ self.grade_re = re.compile ('^(0|[1-9][0-9]?|100|AEG|CR|DNW|INC|IP|NCR|UR|)$')
[docs] def test_process_re_column_no_matches (self): """ Tests process_re_column given a column and a regex with no matches. """ columns = ['not_a_grade', 'not a grade'] self.assertEqual ([None, None], process_re_column (self.grade_re, columns))
[docs] def test_process_re_column_has_matches (self): """ Tests process_re_column given a column and a regex with matches """ columns = ['INC', '100', 'AEG', 'not a grade'] self.assertEqual (['INC', '100', 'AEG', None], process_re_column (self.grade_re, columns))
[docs] def test_find_relevant_columns (self): """ Tests find_relevant_columns () """ grid = [ ['not a match', '20731632'], ['20731209', 'not a match'], ['AEG', 'INC'], ['not a match', '20731211'], ] relevant_columns = ( ['20731632', None, None, '20731211'], [None, None, 'INC', None] ) self.assertEqual (relevant_columns, find_relevant_columns (grid))