From 26ca347c1d25805370e8945ef4585abe4d26ef60 Mon Sep 17 00:00:00 2001 From: deng Date: Thu, 18 Jun 2026 09:37:54 +0800 Subject: [PATCH] test load_config --- tests/__init__.py | 0 tests/test_utils.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_utils.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..f714848 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,23 @@ +# test_utils.py + +import pytest + +from quickdraw_bot.utils.utils import load_config + + +class TestUtils: + def test_load_config_load_valid_yaml(self, tmp_path): + config_file = tmp_path / 'config.yaml' + config_file.write_text('key: value\nnested:\n a: 1\n') + result = load_config(str(config_file)) + assert result == {'key': 'value', 'nested': {'a': 1}} + + def test_load_config_returns_dict(self, tmp_path): + config_file = tmp_path / 'config.yaml' + config_file.write_text('foo: bar\n') + result = load_config(str(config_file)) + assert isinstance(result, dict) + + def test_load_config_file_not_found(self): + with pytest.raises(FileNotFoundError): + load_config('/nonexistent/path/config.yaml')