Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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])
Пример #4
0
 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)
Пример #5
0
 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()
Пример #6
0
 def test_invalid_url(self, url):
     '''test invalid url'''
     test_obj = GoodreadsAPIClient(url=url)
     with pytest.raises(InvalidGoodreadsURL):
         test_obj.url_validator()
Пример #7
0
 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 == {}