We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc91db1 commit fe16d1eCopy full SHA for fe16d1e
1 file changed
nocodb/infra/requests_client_test.py
@@ -0,0 +1,20 @@
1
+from unittest import mock
2
+
3
+import pytest
4
5
+from .requests_client import NocoDBRequestsClient, requests as requests_lib
6
+from ..exceptions import NocoDBAPIError
7
8
9
+@mock.patch.object(requests_lib, "Session")
10
+def test_NocoDBAPIError_raised_on_bad_response(mock_requests_session):
11
+ mock_session = mock.Mock()
12
+ expected_exception = NocoDBAPIError("Error 400 in the request", 400)
13
+ mock_session.request.side_effect = expected_exception
14
+ mock_requests_session.return_value = mock_session
15
+ client = NocoDBRequestsClient(mock.Mock(), "")
16
+ with pytest.raises(NocoDBAPIError) as exc_info:
17
+ client._request("GET", "/")
18
19
+ assert str(exc_info.value) == str(expected_exception)
20
+ assert exc_info.value.status_code == expected_exception.status_code
0 commit comments