File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments