WIP: Overhaul for 4.0.0

This commit is contained in:
kku
2024-12-18 14:16:37 +01:00
parent 5e479ddc79
commit 95d04308bd
32 changed files with 718 additions and 688 deletions

View File

@@ -2,8 +2,7 @@ from pathlib import Path
from typing import Any, List
import pytest
from libbot import sync
from libbot.utils import config_delete, config_get, config_set
@pytest.mark.parametrize(
@@ -13,8 +12,8 @@ from libbot import sync
(["bot_token", "bot"], "sample_token"),
],
)
def test_config_get_valid(args: List[str], expected: str, location_config: Path):
assert sync.config_get(args[0], *args[1:], config_file=location_config) == expected
async def test_config_get_valid(args: List[str], expected: str, location_config: Path):
assert config_get(args[0], *args[1:], config_file=location_config) == expected
@pytest.mark.parametrize(
@@ -25,9 +24,7 @@ def test_config_get_valid(args: List[str], expected: str, location_config: Path)
)
def test_config_get_invalid(args: List[str], expected: Any, location_config: Path):
with expected:
assert (
sync.config_get(args[0], *args[1:], config_file=location_config) == expected
)
assert config_get(args[0], *args[1:], config_file=location_config) == expected
@pytest.mark.parametrize(
@@ -38,8 +35,8 @@ def test_config_get_invalid(args: List[str], expected: Any, location_config: Pat
],
)
def test_config_set(key: str, path: List[str], value: Any, location_config: Path):
sync.config_set(key, value, *path, config_file=location_config)
assert sync.config_get(key, *path, config_file=location_config) == value
config_set(key, value, *path, config_file=location_config)
assert config_get(key, *path, config_file=location_config) == value
@pytest.mark.parametrize(
@@ -49,8 +46,8 @@ def test_config_set(key: str, path: List[str], value: Any, location_config: Path
],
)
def test_config_delete(key: str, path: List[str], location_config: Path):
sync.config_delete(key, *path, config_file=location_config)
assert key not in sync.config_get(*path, config_file=location_config)
config_delete(key, *path, config_file=location_config)
assert key not in config_get(*path, config_file=location_config)
@pytest.mark.parametrize(
@@ -60,7 +57,4 @@ def test_config_delete(key: str, path: List[str], location_config: Path):
],
)
def test_config_delete_missing(key: str, path: List[str], location_config: Path):
assert (
sync.config_delete(key, *path, missing_ok=True, config_file=location_config)
is None
)
assert config_delete(key, *path, missing_ok=True, config_file=location_config) is None