From 6fa24fe609b937894f803275c414d181bdadef7d Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 11 Aug 2023 22:33:56 +0100 Subject: [PATCH] error tests added --- tests/test_error.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/test_error.py diff --git a/tests/test_error.py b/tests/test_error.py new file mode 100644 index 0000000..721c965 --- /dev/null +++ b/tests/test_error.py @@ -0,0 +1,31 @@ +import pytest + +import obsws_python as obsws +from tests import req_cl + + +class TestErrors: + __test__ = True + + def test_it_raises_an_obssdk_error_on_bad_connection_info(self): + bad_conn = {"host": "localhost", "port": 4455, "password": "incorrectpassword"} + with pytest.raises( + obsws.error.OBSSDKError, + match="failed to identify client with the server, please check connection settings", + ): + obsws.ReqClient(**bad_conn) + + def test_it_raises_an_obssdk_error_if_auth_enabled_but_no_password_provided(self): + bad_conn = {"host": "localhost", "port": 4455, "password": ""} + with pytest.raises( + obsws.error.OBSSDKError, + match="authentication enabled but no password provided", + ): + obsws.ReqClient(**bad_conn) + + def test_it_raises_a_request_error_on_invalid_request(self): + with pytest.raises( + obsws.error.OBSSDKRequestError, + match="Request SetCurrentProgramScene returned code 600. With message: No source was found by the name of `invalid`.", + ): + req_cl.set_current_program_scene("invalid")