def test_get_page_should_return_error_message_for_a_403_status_code_page(): saving_zelda = SavingZelda(**zelda_args) with pytest.raises(Exception) as context: saving_zelda.get_page("http://httpbin.org/status/403") assert "Oops! The page returned a status code 403" == context.value.message
def test_get_page_should_return_body_content_for_a_200_status_code_page(): httpretty.register_uri(httpretty.GET, "http://github.com/", body="here is the mocked body", status=200) saving_zelda = SavingZelda(**zelda_args) saving_zelda.get_page("http://github.com/") assert "here is the mocked body" == saving_zelda.body
def test_get_page_should_return_proper_html_content(): httpretty.register_uri(httpretty.GET, "http://saving-zelda.com", body=html_data("simple.html"), status=200) saving_zelda = SavingZelda(**zelda_args) saving_zelda.get_page("http://saving-zelda.com/") soup = BeautifulSoup(saving_zelda.body) assert "Saving Zelda" == soup.title.string