Ejemplo n.º 1
0
 def test_adhoc_function_is_executed_after_fetch(self):
     url = "http://www.google.com"
     expected = 42
     result = challenge.fetch_html_from_url(url, after_fetch=self.return_42)
     self.assertEqual(expected, result)
Ejemplo n.º 2
0
 def test_return_empty_if_redirected(self):
     url = "http://www.americanas.com.br/produto/spam_and_eggs"
     expected = ""
     result = challenge.fetch_html_from_url(url)
     self.assertEqual(expected, result)
Ejemplo n.º 3
0
 def test_get_cookie_and_redirect(self):
     # WARNING: this test can fail due to unavailability of url
     url = "http://hughes.sieve.com.br:9090/level2/"
     expected = "R$ 3.999,00"
     result = challenge.fetch_html_from_url(url, use_cookie=True)
     self.assertTrue(result.find(expected) > 0)
Ejemplo n.º 4
0
 def test_return_empty_when_url_does_not_exist(self):
     url = "http://youaresobeautiful4242.com"
     expected = ""
     result = challenge.fetch_html_from_url(url)
     self.assertEqual(expected, result)