Added some basic test
This commit is contained in:
42
tests/test_config_async.py
Normal file
42
tests/test_config_async.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from typing import Any, List
|
||||
|
||||
import pytest
|
||||
|
||||
from libbot import config_get, config_set
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"args, expected",
|
||||
[
|
||||
(["locale"], "en"),
|
||||
(["bot_token", "bot"], "sample_token"),
|
||||
],
|
||||
)
|
||||
async def test_config_get_valid(args: List[str], expected: str):
|
||||
assert await config_get(args[0], *args[1:]) == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"args, expected",
|
||||
[
|
||||
(["bot_stonks", "bot"], pytest.raises(KeyError)),
|
||||
],
|
||||
)
|
||||
async def test_config_get_invalid(args: List[str], expected: Any):
|
||||
with expected:
|
||||
assert await config_get(args[0], *args[1:]) == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"key, path, value",
|
||||
[
|
||||
("locale", [], "en"),
|
||||
("bot_token", ["bot"], "sample_token"),
|
||||
],
|
||||
)
|
||||
async def test_config_set(key: str, path: List[str], value: Any):
|
||||
await config_set(key, value, *path)
|
||||
assert await config_get(key, *path) == value
|
Reference in New Issue
Block a user