Changed path to tests/
This commit is contained in:
parent
e508f37089
commit
b6537a50ae
@ -1,3 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -14,7 +15,10 @@ from libbot import config_get, config_set
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_config_get_valid(args: List[str], expected: str):
|
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
|
@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):
|
async def test_config_get_invalid(args: List[str], expected: Any):
|
||||||
with expected:
|
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
|
@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):
|
async def test_config_set(key: str, path: List[str], value: Any):
|
||||||
await config_set(key, value, *path)
|
await config_set(key, value, *path, config_file=Path("tests/config.json"))
|
||||||
assert await config_get(key, *path) == value
|
assert await config_get(key, *path, config_file=Path("tests/config.json")) == value
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -13,7 +14,10 @@ from libbot import sync
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_config_get_valid(args: List[str], expected: str):
|
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(
|
@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):
|
def test_config_get_invalid(args: List[str], expected: Any):
|
||||||
with expected:
|
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(
|
@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):
|
def test_config_set(key: str, path: List[str], value: Any):
|
||||||
sync.config_set(key, value, *path)
|
sync.config_set(key, value, *path, config_file=Path("tests/config.json"))
|
||||||
assert sync.config_get(key, *path) == value
|
assert sync.config_get(key, *path, config_file=Path("tests/config.json")) == value
|
||||||
|
@ -12,13 +12,13 @@ from libbot import json_read, json_write
|
|||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"data/test.json",
|
"tests/data/test.json",
|
||||||
{
|
{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
|
"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):
|
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(
|
@pytest.mark.parametrize(
|
||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
("data/invalid.json", pytest.raises(JSONDecodeError)),
|
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
||||||
("data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
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",
|
"foo": "bar",
|
||||||
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
|
"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]):
|
async def test_json_write(data: Any, path: Union[str, Path]):
|
||||||
|
@ -11,13 +11,13 @@ from libbot import sync
|
|||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"data/test.json",
|
"tests/data/test.json",
|
||||||
{
|
{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
|
"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):
|
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(
|
@pytest.mark.parametrize(
|
||||||
"path, expected",
|
"path, expected",
|
||||||
[
|
[
|
||||||
("data/invalid.json", pytest.raises(JSONDecodeError)),
|
("tests/data/invalid.json", pytest.raises(JSONDecodeError)),
|
||||||
("data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
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",
|
"foo": "bar",
|
||||||
"abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}],
|
"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]):
|
def test_json_write(data: Any, path: Union[str, Path]):
|
||||||
|
Loading…
Reference in New Issue
Block a user