mindsdb_python_sdk icon indicating copy to clipboard operation
mindsdb_python_sdk copied to clipboard

test: limited test coverage for RestAPI error scenarios

Open pankaj-bind opened this issue 3 months ago • 3 comments

The test suite in tests/test_sdk.py has limited coverage for RestAPI error scenarios, such as handling 404 Not Found or 500 Internal Server Error responses.

This is because the function responsible for raising HTTP errors is globally mocked, preventing any tests for failure conditions. This can lead to unpredictable behavior in the SDK when it encounters real-world API errors, impacting its robustness and reliability.

The specific line in tests/test_sdk.py that disables error checking is:

# patch _raise_for_status
rest_api._raise_for_status = Mock()

I have developed a solution for this issue. If allowed, I would like to raise a pull request to add proper test coverage for these error cases.

pankaj-bind avatar Sep 04 '25 18:09 pankaj-bind

Hi @ea-rus hope you’re doing well. When you have a moment, could you please review this issue? Your insights would be greatly appreciated. Thank you so much!

pankaj-bind avatar Sep 05 '25 14:09 pankaj-bind

yes, i think this global mock of _raise_for_status can be removed and response_mock function should be used before every sdk call. at the moment it is skipped somewhere, for example for login and status

ea-rus avatar Sep 08 '25 13:09 ea-rus

Exactly

pankaj-bind avatar Sep 08 '25 14:09 pankaj-bind