From ac3cf5f60ec97bfbec4cc204b4e8b6272bb4f17a Mon Sep 17 00:00:00 2001 From: juftin Date: Sun, 17 Dec 2023 09:04:16 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20204=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/models/cassettes/test_204_response.yaml | 52 +++++++++++++++++++ tests/models/test_transactions.py | 17 ++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/models/cassettes/test_204_response.yaml diff --git a/tests/models/cassettes/test_204_response.yaml b/tests/models/cassettes/test_204_response.yaml new file mode 100644 index 00000000..8cf1bb89 --- /dev/null +++ b/tests/models/cassettes/test_204_response.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: '{"transactions":[{"date":"2023-12-17","amount":3.5,"payee":"Test","notes":"Test Transaction Group"}],"apply_rules":false,"skip_duplicates":true,"check_for_recurring":false,"debit_as_negative":false,"skip_balance_update":true}' + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - XXXXXXXXXX + connection: + - keep-alive + content-length: + - '225' + content-type: + - application/json + host: + - dev.lunchmoney.app + user-agent: + - lunchable/1.0.1 + method: POST + uri: https://dev.lunchmoney.app/v1/transactions + response: + content: '' + headers: + Access-Control-Allow-Credentials: + - 'true' + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + Date: + - Sun, 17 Dec 2023 15:58:07 GMT + Etag: + - W/"13-wFA9Dx4FmHqyjCvL9k0g9w+7+E0" + Nel: + - '{"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}' + Report-To: + - '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1702828687&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=fEMUT%2FofMtfxWVkKFLbxjXEBTFvUTnApoF86q3Dt%2By8%3D"}]}' + Reporting-Endpoints: + - heroku-nel=https://nel.heroku.com/reports?ts=1702828687&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=fEMUT%2FofMtfxWVkKFLbxjXEBTFvUTnApoF86q3Dt%2By8%3D + Server: + - Cowboy + Vary: + - Origin, Accept-Encoding + Via: + - 1.1 vegur + X-Powered-By: + - Express + http_version: HTTP/1.1 + status_code: 204 +version: 1 diff --git a/tests/models/test_transactions.py b/tests/models/test_transactions.py index 0adad461..d6097959 100644 --- a/tests/models/test_transactions.py +++ b/tests/models/test_transactions.py @@ -143,3 +143,20 @@ def test_get_uncleared_transactions(lunch_money_obj: LunchMoney) -> None: assert len(uncleared_transactions) >= 1 for transaction in uncleared_transactions: assert isinstance(transaction, TransactionObject) + + +@lunchable_cassette +def test_204_response(lunch_money_obj: LunchMoney) -> None: + """ + Test that a 204 response is handled correctly + + This test includes a hand-edited cassette to simulate a 204 response + """ + test_transaction = TransactionInsertObject( + date=datetime.date.today(), + payee="Test", + notes="Test Transaction Group", + amount=3.50, + ) + response = lunch_money_obj.insert_transactions(transactions=test_transaction) + assert response == []