示例#1
0
 def test_detect_unavailable_product(self):
     html = self.get_html("unavailable.html")
     xpath = "//p[@class='sale price']//span[@class='amount']/text()"
     unv_xpath = "//div[@class='unavailProd']"
     expected = "Unavailable"
     result = challenge.get_raw_price(html, xpath, unv_xpath)
     self.assertEqual(expected, result)
示例#2
0
 def test_get_raw_price_should_return_empty_if_doesnt_find_xpath(self):
     html = self.get_html("example.html")
     xpath = "//p[@class='love is all you need']"
     expected = ""
     result = challenge.get_raw_price(html, xpath)
     self.assertEqual(expected, result)
示例#3
0
 def test_get_price_from_html_level_1_challenge(self):
     html = self.get_html("level1.html")
     xpath = "//div/text()"
     expected = 44.99
     result = challenge.clean_price(challenge.get_raw_price(html, xpath))
     self.assertEqual(expected, result)
示例#4
0
 def test_get_price_from_html_happy_path(self):
     html = self.get_html("example.html")
     xpath = "//p[@class='sale price']//span[@class='amount']/text()"
     expected = "Por: R$ 3.999,00"
     result = challenge.get_raw_price(html, xpath)
     self.assertEqual(expected, result)