From 8d3b2589b0c8ed4ab391ee022067ea506d3f36b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Kub=C3=AD=C4=8Dek?= Date: Tue, 11 Mar 2025 21:16:39 +0100 Subject: [PATCH] test_superfaktura_api: add test download with not writable file descriptor --- test/test_superfaktura_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_superfaktura_api.py b/test/test_superfaktura_api.py index dd034fe..919140a 100644 --- a/test/test_superfaktura_api.py +++ b/test/test_superfaktura_api.py @@ -77,3 +77,13 @@ def test_get_invalid_json(api): mock_get.return_value = mock_response with pytest.raises(SuperFakturaAPIException, match="Unable to decode response as JSON"): api.get("test_endpoint") + +def test_download_not_writable_descriptor(api): + with patch("requests.get") as mock_get: + mock_get.return_value.status_code = 200 + mock_get.return_value.content = b"test_content" + mock_descriptor = MagicMock() + mock_descriptor.writable.return_value = False + with patch("builtins.open", mock_open()) as mock_file: + with pytest.raises(SuperFakturaAPIException, match=" is not writable"): + api.download("test_endpoint", mock_descriptor)