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 Fizzbar
from .interface import FizzbarInterface
@fixture
def interface() -> FizzbarInterface:
return FizzbarInterface(
fizzbar_id=1, name='Test fizzbar', purpose='Test purpose'
)
def test_FizzbarInterface_create(interface: FizzbarInterface):
assert interface
def test_FizzbarInterface_works(interface: FizzbarInterface):
fizzbar = Fizzbar(**interface)
assert fizzbar

View File

@ -0,0 +1,27 @@
from pytest import fixture
from .model import Fizzbar
from .schema import FizzbarSchema
from .interface import FizzbarInterface
@fixture
def schema() -> FizzbarSchema:
return FizzbarSchema()
def test_FizzbarSchema_create(schema: FizzbarSchema):
assert schema
def test_FizzbarSchema_works(schema: FizzbarSchema):
params: FizzbarInterface = schema.load({
'fizzbarId': '123',
'name': 'Test fizzbar',
'purpose': 'Test purpose'
}).data
fizzbar = Fizzbar(**params)
assert fizzbar.fizzbar_id == 123
assert fizzbar.name == 'Test fizzbar'
assert fizzbar.purpose == 'Test purpose'

View File

@ -0,0 +1,19 @@
from pytest import fixture
from .model import Fizzbaz
from .interface import FizzbazInterface
@fixture
def interface() -> FizzbazInterface:
return FizzbazInterface(
fizzbaz_id=1, name='Test fizzbaz', purpose='Test purpose'
)
def test_FizzbazInterface_create(interface: FizzbazInterface):
assert interface
def test_FizzbazInterface_works(interface: FizzbazInterface):
fizzbaz = Fizzbaz(**interface)
assert fizzbaz

View File

@ -0,0 +1,27 @@
from pytest import fixture
from .model import Fizzbaz
from .schema import FizzbazSchema
from .interface import FizzbazInterface
@fixture
def schema() -> FizzbazSchema:
return FizzbazSchema()
def test_FizzbazSchema_create(schema: FizzbazSchema):
assert schema
def test_FizzbazSchema_works(schema: FizzbazSchema):
params: FizzbazInterface = schema.load({
'fizzbazId': '123',
'name': 'Test fizzbaz',
'purpose': 'Test purpose'
}).data
fizzbaz = Fizzbaz(**params)
assert fizzbaz.fizzbaz_id == 123
assert fizzbaz.name == 'Test fizzbaz'
assert fizzbaz.purpose == 'Test purpose'

View File

@ -0,0 +1,19 @@
from pytest import fixture
from .model import Doodad
from .interface import DoodadInterface
@fixture
def interface() -> DoodadInterface:
return DoodadInterface(
doodad_id=1, name='Test doodad', purpose='Test purpose'
)
def test_DoodadInterface_create(interface: DoodadInterface):
assert interface
def test_DoodadInterface_works(interface: DoodadInterface):
doodad = Doodad(**interface)
assert doodad

View File

@ -0,0 +1,27 @@
from pytest import fixture
from .model import Doodad
from .schema import DoodadSchema
from .interface import DoodadInterface
@fixture
def schema() -> DoodadSchema:
return DoodadSchema()
def test_DoodadSchema_create(schema: DoodadSchema):
assert schema
def test_DoodadSchema_works(schema: DoodadSchema):
params: DoodadInterface = schema.load({
'doodadId': '123',
'name': 'Test doodad',
'purpose': 'Test purpose'
}).data
doodad = Doodad(**params)
assert doodad.doodad_id == 123
assert doodad.name == 'Test doodad'
assert doodad.purpose == 'Test purpose'

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'