def test_error_get_news(mock_requests, mock_error): mock_requests.get.return_value.status_code = 401 mock_requests.get.return_value.text = "unauthorized" api = PublicAPI("ABCD") api.get_news() mock_error.assert_called_with( "Error while sending API call 'get news': 401 unauthorized")
def test_get_news(mock_requests, mock_info): mock_requests.get.return_value.status_code = 200 api = PublicAPI(TOKEN) api.get_news() mock_requests.get.assert_called_once_with( f"https://connectapi.feuersoftware.com/interfaces/public/news", headers={"authorization": f"bearer {TOKEN}", "accept": "application/json", "content-type": "application/json"}) mock_info.assert_called_with("Success, API call 'get news' complete")
def test_get_news(mock_requests, mock_info): mock_requests.get.return_value.status_code = 200 api = PublicAPI(TOKEN) api.get_news() mock_requests.get.assert_called_once_with( f"https://connectapi.feuersoftware.com/interfaces/public/news", headers={ "authorization": f"bearer {TOKEN}", "accept": "application/json", "content-type": "application/json" }) mock_info.assert_called_with("Success, API call 'get news' complete")
def test_error_get_news(mock_requests, mock_error): mock_requests.get.return_value.status_code = 401 mock_requests.get.return_value.text = "unauthorized" api = PublicAPI("ABCD") api.get_news() mock_error.assert_called_with("Error while sending API call 'get news': 401 unauthorized")