From 6e0188747232a3a4d67c898f3c40bd71367c494b Mon Sep 17 00:00:00 2001 From: eeshsaxena Date: Sun, 5 Jul 2026 20:57:11 +0530 Subject: [PATCH] test: add unit tests for _get_valid_timeout_config --- test/test_timeout_config.py | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/test_timeout_config.py diff --git a/test/test_timeout_config.py b/test/test_timeout_config.py new file mode 100644 index 000000000..1772db8a7 --- /dev/null +++ b/test/test_timeout_config.py @@ -0,0 +1,41 @@ +import pytest + +from weaviate.util import _get_valid_timeout_config + + +class TestGetValidTimeoutConfig: + """Validation for the client's ``timeout_config`` argument.""" + + def test_single_int_expands_to_pair(self): + assert _get_valid_timeout_config(5) == (5, 5) + + def test_single_float_expands_to_pair(self): + assert _get_valid_timeout_config(2.5) == (2.5, 2.5) + + def test_valid_tuple_returned_unchanged(self): + assert _get_valid_timeout_config((2, 3)) == (2, 3) + + @pytest.mark.parametrize("value", [0, -1, -0.5]) + def test_non_positive_number_raises_value_error(self, value): + with pytest.raises(ValueError): + _get_valid_timeout_config(value) + + @pytest.mark.parametrize("value", [(1,), (1, 2, 3)]) + def test_wrong_length_tuple_raises_value_error(self, value): + with pytest.raises(ValueError): + _get_valid_timeout_config(value) + + @pytest.mark.parametrize("value", [(1, -2), (-1, 2)]) + def test_non_positive_in_tuple_raises_value_error(self, value): + with pytest.raises(ValueError): + _get_valid_timeout_config(value) + + @pytest.mark.parametrize("value", [None, "abc", True]) + def test_non_number_raises_type_error(self, value): + with pytest.raises(TypeError): + _get_valid_timeout_config(value) + + @pytest.mark.parametrize("value", [("a", 2), (True, False)]) + def test_non_number_in_tuple_raises_type_error(self, value): + with pytest.raises(TypeError): + _get_valid_timeout_config(value)