Got the Typeguard thing to finally stop complaining.
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
@@ -3,7 +3,6 @@ import dataclasses
|
||||
import datetime
|
||||
import typing
|
||||
|
||||
import marshmallow
|
||||
import pytest
|
||||
|
||||
from playlist.data import base
|
||||
@@ -21,62 +20,30 @@ class Dummy(base.BaseData):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummyannotations() -> dict[str, typing.Any]:
|
||||
"""Make a dummy annotation dict for testing."""
|
||||
return {
|
||||
"name": str,
|
||||
"some_id": int,
|
||||
"calc": float,
|
||||
"flag": bool,
|
||||
"modified": str,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def modified_date() -> datetime.datetime:
|
||||
"""Make a reusable datetime for testing."""
|
||||
return datetime.datetime.now()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummydict(modified_date: datetime.datetime) -> dict[str, typing.Any]:
|
||||
"""Make a dummy dictionary for testing."""
|
||||
return {
|
||||
"name": "Something",
|
||||
"some_id": 1,
|
||||
"calc": 0.1,
|
||||
"flag": True,
|
||||
"modified": "T".join(str(modified_date).split(" ")),
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummyobj(modified_date: datetime.datetime) -> Dummy:
|
||||
def dummyobj() -> Dummy:
|
||||
"""Make a dummy object for testing."""
|
||||
return Dummy(
|
||||
name="Something",
|
||||
some_id=1,
|
||||
calc=0.1,
|
||||
flag=True,
|
||||
modified=modified_date,
|
||||
modified=datetime.datetime.now(),
|
||||
)
|
||||
|
||||
|
||||
def test_schema() -> None:
|
||||
"""Validate that <data class>.Schema works."""
|
||||
result = isinstance(Dummy.Schema, marshmallow.Schema)
|
||||
|
||||
assert result
|
||||
@pytest.fixture
|
||||
def dummydict(dummyobj: Dummy) -> dict[str, object]:
|
||||
"""Make a dummy dictionary for testing."""
|
||||
return {
|
||||
"name": dummyobj.name,
|
||||
"some_id": dummyobj.some_id,
|
||||
"calc": dummyobj.calc,
|
||||
"flag": dummyobj.flag,
|
||||
"modified": "T".join(str(dummyobj.modified).split(" ")),
|
||||
}
|
||||
|
||||
|
||||
def test_dict(dummyannotations: dict[str, typing.Any]) -> None:
|
||||
"""Validate that <data class>.Dict works."""
|
||||
result = Dummy.Dict.__annotations__ == dummyannotations
|
||||
|
||||
assert result
|
||||
|
||||
|
||||
def test_load(dummydict: base.DataDict, dummyobj: Dummy) -> None:
|
||||
def test_load(dummydict: dict[str, object], dummyobj: Dummy) -> None:
|
||||
"""Validate that <data class>.load() works."""
|
||||
result: Dummy = Dummy.load(dummydict)
|
||||
assert result == dummyobj
|
||||
|
||||
Reference in New Issue
Block a user