def test_not_matching_regex_and_template(self): chapter_strings = [ ['>> +CHAPTER (?P<foo>\\d+) ?[:-] (?P<bar>.+)', '{num} - {name}'], ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{fishies}'] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_empty_lists(self): chapter_strings = [ [], ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{num}'] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_wrong_size_lists(self): chapter_strings = [ ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{num}', 'another one?'], ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{num}'] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_empty_string_data(self): chapter_strings = [ [' ', '{num} - {name}'], ['>> +CHAPTER (?P<num>\\d+)\\s*$', ''] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_invalid_regex(self): chapter_strings = [ ['>> +CHAPTER (?P<num>\\d+)) ?[:-] (?P<name>.+)', '{num} - {name}'], ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{num}'] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_wrong_size_lists(self): chapter_strings = [ [">> +CHAPTER (?P<num>\\d+)\\s*$", "{num}", "another one?"], [">> +CHAPTER (?P<num>\\d+)\\s*$", "{num}"], ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_nonstring_data(self): chapter_strings = [ [12, 1555] ] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_valid_data(self): chapter_strings = [ ['>> +CHAPTER (?P<num>\\d+) ?[:-] (?P<name>.+)', '{num} - {name}'], ['>> +CHAPTER (?P<num>\\d+)\\s*$', '{num}'] ] self.assertIsNone(validate_chapter_strings(chapter_strings))
def test_empty_string_data(self): chapter_strings = [[" ", "{num} - {name}"], [">> +CHAPTER (?P<num>\\d+)\\s*$", ""]] with self.assertRaises(AssertionError): validate_chapter_strings(chapter_strings)
def test_valid_data(self): chapter_strings = [ [">> +CHAPTER (?P<num>\\d+) ?[:-] (?P<name>.+)", "{num} - {name}"], [">> +CHAPTER (?P<num>\\d+)\\s*$", "{num}"], ] self.assertIsNone(validate_chapter_strings(chapter_strings))