def test_escaped_slash_replacement(self): """ Escaped forward slashes in the replace portion of the command are parsed correctly. """ self.assertEqual( process(r's/\/img/http:\/\/sample.com\/img/', '/img/cool.jpg'), 'http://sample.com/img/cool.jpg')
def process_url(self, url): if self.url_processor: try: return process(self.url_processor, url) except Exception, e: logger.error("could not parse url_processor '%s': %s" % (self.url_processor, e)) raise e
def test_parsing_inner_backslash(self): """ An escaped forward slashes inside the substitute command is parsed correctly. """ self.assertEqual( process(r's/http:\/\/google.com/google/', 'http://google.com/home'), 'google/home')
def test_escaped_slash_replacement(self): """ Escaped forward slashes in the replace portion of the command are parsed correctly. """ self.assertEqual(process(r's/\/img/http:\/\/sample.com\/img/', '/img/cool.jpg'), 'http://sample.com/img/cool.jpg')
def test_parsing_leading_and_trailing_backslash(self): """ Leading and trailing escaped forward slashes in the find portion of the substitute command are parsed correctly. """ self.assertEqual(process(r's/\/img//', '/img/cool.jpg'), '/cool.jpg')
def test_parsing_inner_backslash(self): """ An escaped forward slashes inside the substitute command is parsed correctly. """ self.assertEqual(process(r's/http:\/\/google.com/google/', 'http://google.com/home'), 'google/home')
def test_parsing_simple_command(self): """ A simple substitution can be made. """ self.assertEqual(process(r's/if/else/', 'if'), 'else')
def test_parsing_empty_command(self): """ Forward slashes should be properly recognized. """ self.assertEqual(process(r's///', 'same'), 'same')
def test_parsing_leading_and_trailing_backslash(self): """ Leading and trailing escaped forward slashes in the find portion of the substitute command are parsed correctly. """ self.assertEqual(process(r's/\/img//', '/img/cool.jpg'), '/cool.jpg')
def test_parsing_simple_command(self): """ A simple substitution can be made. """ self.assertEqual(process(r's/if/else/', 'if'), 'else')
def test_parsing_empty_command(self): """ Forward slashes should be properly recognized. """ self.assertEqual(process(r's///', 'same'), 'same')