Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/TransactionsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ Name | Type | Description | Notes

| Status code | Description | Response headers |
|-------------|-------------|------------------|
**209** | The transactions were successfully updated | - |
**200** | The transactions were successfully updated | - |
**400** | The request could not be understood due to malformed syntax or validation error(s). | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion open_api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ paths:
$ref: "#/components/schemas/PatchTransactionsWrapper"
required: true
responses:
"209":
"200":
description: The transactions were successfully updated
content:
application/json:
Expand Down
41 changes: 40 additions & 1 deletion tests/test_response_deserialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch

import ynab
from ynab.api.transactions_api import TransactionsApi
from ynab.api_client import ApiClient
from ynab.rest import RESTResponse

Expand Down Expand Up @@ -35,3 +37,40 @@ def test_deserialize_user_response():

assert result.status_code == 200
assert str(result.data.data.user.id) == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"


def test_update_transactions_with_http_info_deserializes_real_200_response():
"""Regression test: TransactionsApi.update_transactions must map status
200, not 209, in its own generated _response_types_map.

The spec previously declared updateTransactions' success response as
HTTP 209, but the real API returns 200. Since 200 didn't match the
hardcoded map inside update_transactions/_with_http_info/
_without_preload_content, every real, successful call silently
deserialized to data=None -- callers had no way to tell the request
had in fact succeeded. This calls the real generated method (not a
hand-supplied response_types_map) so it actually exercises the fixed
value embedded in transactions_api.py.
"""
client = ApiClient()
rest_resp = make_rest_response(200, {
"data": {
"transaction_ids": ["aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"],
"transactions": [],
"duplicate_import_ids": [],
"server_knowledge": 1,
}
})

with patch.object(ApiClient, "call_api", return_value=rest_resp):
api = TransactionsApi(client)
result = api.update_transactions_with_http_info(
plan_id="last-used",
data=ynab.PatchTransactionsWrapper(transactions=[]),
)

assert result.status_code == 200
assert result.data is not None
assert result.data.data.transaction_ids == [
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
]
6 changes: 3 additions & 3 deletions ynab/api/transactions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3344,7 +3344,7 @@ def update_transactions(
)

_response_types_map: Dict[str, Optional[str]] = {
'209': "SaveTransactionsResponse",
'200': "SaveTransactionsResponse",
'400': "ErrorResponse",
}
response_data = self.api_client.call_api(
Expand Down Expand Up @@ -3416,7 +3416,7 @@ def update_transactions_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'209': "SaveTransactionsResponse",
'200': "SaveTransactionsResponse",
'400': "ErrorResponse",
}
response_data = self.api_client.call_api(
Expand Down Expand Up @@ -3488,7 +3488,7 @@ def update_transactions_without_preload_content(
)

_response_types_map: Dict[str, Optional[str]] = {
'209': "SaveTransactionsResponse",
'200': "SaveTransactionsResponse",
'400': "ErrorResponse",
}
response_data = self.api_client.call_api(
Expand Down