Changed path to tests/

This commit is contained in:
Profitroll 2023-08-06 02:08:02 +02:00
parent e508f37089
commit b6537a50ae
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
4 changed files with 34 additions and 20 deletions

View File

@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any, List
import pytest
@ -14,7 +15,10 @@ from libbot import config_get, config_set
],
)
async def test_config_get_valid(args: List[str], expected: str):
assert await config_get(args[0], *args[1:]) == expected
assert (
await config_get(args[0], *args[1:], config_file=Path("tests/config.json"))
== expected
)
@pytest.mark.asyncio
@ -26,7 +30,10 @@ async def test_config_get_valid(args: List[str], expected: str):
)
async def test_config_get_invalid(args: List[str], expected: Any):
with expected:
assert await config_get(args[0], *args[1:]) == expected
assert (
await config_get(args[0], *args[1:], config_file=Path("tests/config.json"))
== expected
)
@pytest.mark.asyncio
@ -38,5 +45,5 @@ async def test_config_get_invalid(args: List[str], expected: Any):
],
)
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
await config_set(key, value, *path, config_file=Path("tests/config.json"))
assert await config_get(key, *path, config_file=Path("tests/config.json")) == value

View File

@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any, List
import pytest
@ -13,7 +14,10 @@ from libbot import sync
],
)
def test_config_get_valid(args: List[str], expected: str):
assert sync.config_get(args[0], *args[1:]) == expected
assert (
sync.config_get(args[0], *args[1:], config_file=Path("tests/config.json"))
== expected
)
@pytest.mark.parametrize(
@ -24,7 +28,10 @@ def test_config_get_valid(args: List[str], expected: str):
)
def test_config_get_invalid(args: List[str], expected: Any):
with expected:
assert sync.config_get(args[0], *args[1:]) == expected
assert (
sync.config_get(args[0], *args[1:], config_file=Path("tests/config.json"))
== expected
)
@pytest.mark.parametrize(
@ -35,5 +42,5 @@ def test_config_get_invalid(args: List[str], expected: Any):
],
)
def test_config_set(key: str, path: List[str], value: Any):
sync.config_set(key, value, *path)
assert sync.config_get(key, *path) == value
sync.config_set(key, value, *path, config_file=Path("tests/config.json"))
assert sync.config_get(key, *path, config_file=Path("tests/config.json")) == value

View File

@ -12,13 +12,13 @@ from libbot import json_read, json_write
"path, expected",
[
(
"data/test.json",
"tests/data/test.json",
{
"foo": "bar",
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
},
),
("data/empty.json", {}),
("tests/data/empty.json", {}),
],
)
async def test_json_read_valid(path: Union[str, Path], expected: Any):
@ -29,8 +29,8 @@ async def test_json_read_valid(path: Union[str, Path], expected: Any):
@pytest.mark.parametrize(
"path, expected",
[
("data/invalid.json", pytest.raises(JSONDecodeError)),
("data/nonexistent.json", pytest.raises(FileNotFoundError)),
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
],
)
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
@ -47,9 +47,9 @@ async def test_json_read_invalid(path: Union[str, Path], expected: Any):
"foo": "bar",
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
},
"data/test.json",
"tests/data/test.json",
),
({}, "data/empty.json"),
({}, "tests/data/empty.json"),
],
)
async def test_json_write(data: Any, path: Union[str, Path]):

View File

@ -11,13 +11,13 @@ from libbot import sync
"path, expected",
[
(
"data/test.json",
"tests/data/test.json",
{
"foo": "bar",
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
},
),
("data/empty.json", {}),
("tests/data/empty.json", {}),
],
)
def test_json_read_valid(path: Union[str, Path], expected: Any):
@ -27,8 +27,8 @@ def test_json_read_valid(path: Union[str, Path], expected: Any):
@pytest.mark.parametrize(
"path, expected",
[
("data/invalid.json", pytest.raises(JSONDecodeError)),
("data/nonexistent.json", pytest.raises(FileNotFoundError)),
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
],
)
def test_json_read_invalid(path: Union[str, Path], expected: Any):
@ -44,9 +44,9 @@ def test_json_read_invalid(path: Union[str, Path], expected: Any):
"foo": "bar",
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
},
"data/test.json",
"tests/data/test.json",
),
({}, "data/empty.json"),
({}, "tests/data/empty.json"),
],
)
def test_json_write(data: Any, path: Union[str, Path]):