mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-10-04 17:36:23 +00:00
⚡️ Refactor LiteyukiBot structure and add configuration loading
- Updated .gitignore to include .pytest_cache - Replaced FastAPI with Daemon in main.py for bot execution - Enhanced pyproject.toml with new dependencies and dev group - Added iniconfig package for pytest configuration - Created initial structure for liteyukibot with context management - Implemented configuration loading functions for YAML, JSON, and TOML - Added tests for configuration loading with temporary files - Set up GitHub Actions for pytest testing on push and pull requests
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
43
tests/test_config.py
Normal file
43
tests/test_config.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import tempfile
|
||||
from liteyukibot import config
|
||||
|
||||
|
||||
def test_load_from_yaml():
|
||||
# 创建一个临时 YAML 文件内容
|
||||
yaml_content = """
|
||||
name: LiteyukiBot
|
||||
version: 7.0.0
|
||||
"""
|
||||
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".yaml") as temp_file:
|
||||
temp_file.write(yaml_content)
|
||||
temp_file_path = temp_file.name
|
||||
|
||||
result = config.load_from_yaml(temp_file_path)
|
||||
assert result["name"] == "LiteyukiBot"
|
||||
assert result["version"] == "7.0.0"
|
||||
|
||||
|
||||
def test_load_from_json():
|
||||
json_content = '{"name": "LiteyukiBot", "version": "7.0.0"}'
|
||||
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".json") as temp_file:
|
||||
temp_file.write(json_content)
|
||||
temp_file_path = temp_file.name
|
||||
|
||||
result = config.load_from_json(temp_file_path)
|
||||
assert result["name"] == "LiteyukiBot"
|
||||
assert result["version"] == "7.0.0"
|
||||
|
||||
|
||||
def test_load_from_toml():
|
||||
toml_content = """
|
||||
[info]
|
||||
name = "LiteyukiBot"
|
||||
version = "7.0.0"
|
||||
"""
|
||||
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".toml") as temp_file:
|
||||
temp_file.write(toml_content)
|
||||
temp_file_path = temp_file.name
|
||||
|
||||
result = config.load_from_toml(temp_file_path)
|
||||
assert result["info"]["name"] == "LiteyukiBot"
|
||||
assert result["info"]["version"] == "7.0.0"
|
Reference in New Issue
Block a user