def test_pattern_to_regex_escaped_literals(self): result = pattern_to_regex("${*}") self.assertEquals(result, "\*") result = pattern_to_regex("${?}") self.assertEquals(result, "\?") result = pattern_to_regex("${$}") self.assertEquals(result, "\$")
def test_pattern_to_regex_varaible_invalid_name(self): with self.assertRaises(ValueError): pattern_to_regex("${ }") with self.assertRaises(ValueError): pattern_to_regex("${1A}") with self.assertRaises(ValueError): pattern_to_regex("${!}")
def test_pattern_to_regex_invalid_end_bracket(self): with self.assertRaises(ValueError): pattern_to_regex("${value") with self.assertRaises(ValueError): pattern_to_regex("$") with self.assertRaises(ValueError): pattern_to_regex("}${")
def test_pattern_to_regex_empty_pattern(self): result = pattern_to_regex("") self.assertEqual(result, "")
def test_pattern_to_regex_variable(self): result = pattern_to_regex("${variablename}") self.assertEquals(result, "(?P<variablename>.*)") result = pattern_to_regex("${variablename}", "^:") self.assertEquals(result, "(?P<variablename>^:*)")
def test_pattern_to_regex_wildcard_single(self): result = pattern_to_regex("?") self.assertEquals(result, ".") result = pattern_to_regex("?", "^:") self.assertEquals(result, "^:")
def test_pattern_to_regex_wildcard_multiple(self): result = pattern_to_regex("*") self.assertEquals(result, ".*") result = pattern_to_regex("*", "^:") self.assertEquals(result, "^:*")
def test_pattern_to_regex_literals(self): result = pattern_to_regex(".+-") self.assertEquals(result, "\.\+\-")
def test_pattern_to_regex_varaible_empty_name(self): with self.assertRaises(ValueError): pattern_to_regex("${}")
def test_pattern_to_regex_invalid_start_bracket(self): with self.assertRaises(ValueError): pattern_to_regex("$ {value}") with self.assertRaises(ValueError): pattern_to_regex("$}{")