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