Add schema and interface tests

This commit is contained in:
Alan Pryor
2019-05-19 10:56:56 -04:00
parent 98e270402c
commit 207adab0fc
8 changed files with 184 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
from pytest import fixture
from .model import Whatsit
from .interface import WhatsitInterface
@fixture
def interface() -> WhatsitInterface:
return WhatsitInterface(
whatsit_id=1, name='Test whatsit', purpose='Test purpose'
)
def test_WhatsitInterface_create(interface: WhatsitInterface):
assert interface
def test_WhatsitInterface_works(interface: WhatsitInterface):
whatsit = Whatsit(**interface)
assert whatsit

View File

@@ -0,0 +1,27 @@
from pytest import fixture
from .model import Whatsit
from .schema import WhatsitSchema
from .interface import WhatsitInterface
@fixture
def schema() -> WhatsitSchema:
return WhatsitSchema()
def test_WhatsitSchema_create(schema: WhatsitSchema):
assert schema
def test_WhatsitSchema_works(schema: WhatsitSchema):
params: WhatsitInterface = schema.load({
'whatsitId': '123',
'name': 'Test whatsit',
'purpose': 'Test purpose'
}).data
whatsit = Whatsit(**params)
assert whatsit.whatsit_id == 123
assert whatsit.name == 'Test whatsit'
assert whatsit.purpose == 'Test purpose'