Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 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')
Ejemplo n.º 6
0
 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')
Ejemplo n.º 7
0
 def test_parsing_simple_command(self):
     """
     A simple substitution can be made.
     """
     self.assertEqual(process(r's/if/else/', 'if'), 'else')
Ejemplo n.º 8
0
 def test_parsing_empty_command(self):
     """
     Forward slashes should be properly recognized.
     """
     self.assertEqual(process(r's///', 'same'), 'same')
Ejemplo n.º 9
0
 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')
Ejemplo n.º 10
0
 def test_parsing_simple_command(self):
     """
     A simple substitution can be made.
     """
     self.assertEqual(process(r's/if/else/', 'if'), 'else')
Ejemplo n.º 11
0
 def test_parsing_empty_command(self):
     """
     Forward slashes should be properly recognized.
     """
     self.assertEqual(process(r's///', 'same'), 'same')