def test_valid_url(self, url): '''test validating valid url''' test_obj = GoodreadsAPIClient(url=url) try : test_obj.url_validator() except InvalidGoodreadsURL: assert False else : assert True
def test_service_caller_200OK(self, url): '''test service caller method''' time.sleep(2) test_obj = GoodreadsAPIClient(url=url) try : test_obj.service_caller() except InvalidGoodreadsURL: assert False else : assert True
def test_get_book_details(self,url): '''test the OG method''' time.sleep(2) test_obj = GoodreadsAPIClient() try : out_ = test_obj.get_book_details(url=url) except : assert False else : self.assertIsInstance(out_, dict) for key, value in out_.items(): self.assertIsInstance(value,test_obj.out_blueprint[key])
def test_valid_xml_parser(self,url): '''test xml parser method with valid xml''' time.sleep(2) test_obj = GoodreadsAPIClient(url=url) try: test_obj.url_validator() test_obj.service_caller() test_obj.xml_parser() except InvalidGoodreadsURL: assert False except ServiceCallException: assert False else: self.assertIsInstance(test_obj._out, dict)
def test_service_caller_NOTOK(self, url): '''test service caller method''' time.sleep(2) test_obj = GoodreadsAPIClient(url=url) with pytest.raises(ServiceCallException): test_obj.service_caller()
def test_invalid_url(self, url): '''test invalid url''' test_obj = GoodreadsAPIClient(url=url) with pytest.raises(InvalidGoodreadsURL): test_obj.url_validator()
def test_invalid_xml_parser(self,service_content): '''test xml parser method with invalid xml''' test_obj = GoodreadsAPIClient(service_content=service_content) test_obj.xml_parser() assert test_obj._out == {}