Add schema and interface tests
This commit is contained in:
parent
1ef26d3b60
commit
98e270402c
0
app/fizz/fizzbar/interface_test.py
Normal file
0
app/fizz/fizzbar/interface_test.py
Normal file
19
app/widget/interface_test.py
Normal file
19
app/widget/interface_test.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from pytest import fixture
|
||||||
|
from .model import Widget
|
||||||
|
from .interface import WidgetInterface
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def interface() -> WidgetInterface:
|
||||||
|
return WidgetInterface(
|
||||||
|
widget_id=1, name='Test widget', purpose='Test purpose'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_WidgetInterface_create(interface: WidgetInterface):
|
||||||
|
assert interface
|
||||||
|
|
||||||
|
|
||||||
|
def test_WidgetInterface_works(interface: WidgetInterface):
|
||||||
|
widget = Widget(**interface)
|
||||||
|
assert widget
|
|
@ -1,7 +1,6 @@
|
||||||
from sqlalchemy import Integer, Column, String
|
from sqlalchemy import Integer, Column, String
|
||||||
from app import db # noqa
|
from app import db # noqa
|
||||||
from .interface import WidgetInterface
|
from .interface import WidgetInterface
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
class Widget(db.Model): # type: ignore
|
class Widget(db.Model): # type: ignore
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
from pytest import fixture
|
||||||
|
|
||||||
|
from .model import Widget
|
||||||
|
from .schema import WidgetSchema
|
||||||
|
from .interface import WidgetInterface
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def schema() -> WidgetSchema:
|
||||||
|
return WidgetSchema()
|
||||||
|
|
||||||
|
|
||||||
|
def test_WidgetSchema_create(schema: WidgetSchema):
|
||||||
|
assert schema
|
||||||
|
|
||||||
|
|
||||||
|
def test_WidgetSchema_works(schema: WidgetSchema):
|
||||||
|
params: WidgetInterface = schema.load({
|
||||||
|
'widgetId': '123',
|
||||||
|
'name': 'Test widget',
|
||||||
|
'purpose': 'Test purpose'
|
||||||
|
}).data
|
||||||
|
widget = Widget(**params)
|
||||||
|
|
||||||
|
assert widget.widget_id == 123
|
||||||
|
assert widget.name == 'Test widget'
|
||||||
|
assert widget.purpose == 'Test purpose'
|
Loading…
Reference in New Issue
Block a user