40 lines
886 B
Python
40 lines
886 B
Python
from typing import Any, List
|
|
|
|
import pytest
|
|
|
|
from libbot import sync
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"args, expected",
|
|
[
|
|
(["locale"], "en"),
|
|
(["bot_token", "bot"], "sample_token"),
|
|
],
|
|
)
|
|
def test_config_get_valid(args: List[str], expected: str):
|
|
assert sync.config_get(args[0], *args[1:]) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"args, expected",
|
|
[
|
|
(["bot_stonks", "bot"], pytest.raises(KeyError)),
|
|
],
|
|
)
|
|
def test_config_get_invalid(args: List[str], expected: Any):
|
|
with expected:
|
|
assert sync.config_get(args[0], *args[1:]) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"key, path, value",
|
|
[
|
|
("locale", [], "en"),
|
|
("bot_token", ["bot"], "sample_token"),
|
|
],
|
|
)
|
|
def test_config_set(key: str, path: List[str], value: Any):
|
|
sync.config_set(key, value, *path)
|
|
assert sync.config_get(key, *path) == value
|