Ejemplo n.º 1
0
    def test_parser_works_correctly(self):
        # Loop test cases data for `parse_course_str`
        for raw, expected in course_str_data.items():
            parsed = parse_course_str(raw)
            match = (parsed['dept'], parsed['course'], parsed['section'],
                     parsed['flags'])

            self.assertEqual(
                match, expected,
                'Expected and parsed course string data does not match')
Ejemplo n.º 2
0
 def type_filter(course_key) -> bool:
     # {'standard':1, 'online':1, 'hybrid':0}
     if 'types' not in filters:
         return True
     # Compute filters
     types = set()
     for name, include in filters['types'].items():
         if not include:
             continue
         types.add(name)
     # Get course flags
     course_str = course[course_key][0]['course']
     flags = parse_course_str(course_str)['flags']
     class_type = get_class_type(campus, flags)
     return class_type in types
Ejemplo n.º 3
0
 def test_error_with_invalid_course_part_format3(self):
     # Test string with invalid course part ('F01A-' does not match fully due to trailing '-')
     with raises(ValidationError) as error_info:
         parse_course_str('CS F01A-00')
     show(error_info)
Ejemplo n.º 4
0
 def test_error_with_invalid_course_part_format2(self):
     # Test string with invalid course part ('FXXXX' has an invalid format - no numbers)
     with raises(ValidationError) as error_info:
         parse_course_str('CS FXXXX00')
     show(error_info)
Ejemplo n.º 5
0
 def test_error_with_invalid_course_part_format1(self):
     # Test string with invalid course part ('X001C' starts with invalid 'X')
     with raises(ValidationError) as error_info:
         parse_course_str('CS X001C01')
     show(error_info)
Ejemplo n.º 6
0
 def test_error_with_too_long_course_section_part(self):
     # Test string with invalid course + section string (last part - 'D001CXXXX')
     # Length is greater than 8
     with raises(ValidationError) as error_info:
         parse_course_str('CIS D001CXXXX')
     show(error_info)
Ejemplo n.º 7
0
 def test_error_with_too_short_course_section_part(self):
     # Test string with invalid course + section string (last part)
     # Length is less than 8
     with raises(ValidationError) as error_info:
         parse_course_str('CIS D00F')
     show(error_info)
Ejemplo n.º 8
0
 def test_error_with_invalid_num_of_parts(self):
     # Test string with less than 2 space-separated parts
     with raises(ValidationError) as error_info:
         parse_course_str('CS ')
     show(error_info)
Ejemplo n.º 9
0
 def test_error_on_empty_str(self):
     # Test empty string
     with raises(ValidationError) as error_info:
         parse_course_str('')
     show(error_info)