def test_link_at_the_end_of_a_file(self):
     text = 'abc http://example.com/search?source=a&page=b'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/search?source=a&page=b)')
 def test_excludes_trailing_comma_at_end_of_query(self):
     text = 'abc http://example.com/search?source=a&page=b, def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/search?source=a&page=b), def')
 def test_link_at_the_start_of_a_file(self):
     text = 'http://example.com/search?source=a&page=b def'
     self.assertEqual(clean_up_http_links(text), '[link](http://example.com/search?source=a&page=b) def')
 def test_http_link_does_not_truncate_query_with_ampersand(self):
     text = 'abc http://example.com/search?source=a&page=b def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/search?source=a&page=b) def')
 def test_http_link_does_not_truncate_path_ending_with_word_character(self):
     text = 'abc http://example.com/search def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/search) def')
 def test_http_link_does_not_truncate_forward_slash(self):
     text = 'abc http://example.com/ def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/) def')
 def test_http_link_does_not_truncate_query(self):
     text = 'abc http://example.com/search?source=abc def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com/search?source=abc) def')
 def test_excludes_trailing_closing_parenthesis(self):
     text = 'abc http://example.com) def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com)) def')
 def test_http_link_does_not_truncate_equals_sign(self):
     text = 'abc http://example.com=434 def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com=434) def')
 def test_excludes_trailing_comma_from_link(self):
     text = 'abc http://example.com, def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com), def')
 def test_handles_urls_with_dash_in_the_host_name(self):
     text = 'http://www.cra-arc.gc.ca/tx/ndvdls/vlntr/menu-eng.html'
     expected = '[link](http://www.cra-arc.gc.ca/tx/ndvdls/vlntr/menu-eng.html)'
     self.assertEqual(clean_up_http_links(text), expected)
 def test_replaces_https_link_with_markdown(self):
     text = 'https://example.com'
     self.assertEqual(clean_up_http_links(text), '[link](https://example.com)')
 def test_replaces_two_links_with_markdown(self):
     text = 'abc http://example.com def http://example.org ghi'
     expected = 'abc [link](http://example.com) def [link](http://example.org) ghi'
     self.assertEqual(clean_up_http_links(text), expected)
 def test_replaces_http_link_with_markdown(self):
     text = 'abc http://example.com def'
     self.assertEqual(clean_up_http_links(text), 'abc [link](http://example.com) def')