Compare commits

..

2 Commits

Author SHA1 Message Date
26ca347c1d test load_config 2026-06-18 09:37:54 +08:00
649533cb17 mod arg 2026-06-18 09:29:56 +08:00
3 changed files with 24 additions and 1 deletions

View File

@ -27,7 +27,7 @@ repos:
- id: pytest - id: pytest
name: pytest name: pytest
entry: uv run pytest tests/ -v entry: uv run pytest tests/ -vs
language: system language: system
pass_filenames: false pass_filenames: false
stages: [pre-push] stages: [pre-push]

0
tests/__init__.py Normal file
View File

23
tests/test_utils.py Normal file
View File

@ -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')