async def test_create(session: Session): # noqa yin: FizzSchema = FizzSchema(fizz_id=1, name="Yin", purpose="thing 1") await FizzService.create(yin, session) results: List[Fizz] = session.query(Fizz).all() assert len(results) == 1 for k in yin.dict().keys(): assert getattr(results[0], k) == getattr(yin, k)
async def test_create(session: Session): # noqa yin: WidgetSchema = WidgetSchema(widget_id=1, name="Yin", purpose="thing 1") await WidgetService.create(yin, session) results: List[Widget] = session.query(Widget).all() assert len(results) == 1 for k in yin.dict().keys(): assert getattr(results[0], k) == getattr(yin, k)
async def test_update(session: Session): # noqa yin: FizzSchema = FizzSchema(fizz_id=1, name="Yin", purpose="thing 1") yin_orm = Fizz(**yin.dict()) session.add(yin_orm) updates: FizzSchema = FizzSchema(fizz_id=1, name="New Fizz name", purpose="thing 1") await FizzService.update(yin_orm, updates, session) result: FizzSchema = session.query(Fizz).get(yin.fizz_id) assert result.name == "New Fizz name"
async def test_update(session: Session): # noqa yin: WidgetSchema = WidgetSchema(widget_id=1, name="Yin", purpose="thing 1") yin_orm = Widget(**yin.dict()) session.add(yin_orm) updates: WidgetSchema = WidgetSchema( widget_id=1, name="New Widget name", purpose="thing 1" ) await WidgetService.update(yin_orm, updates, session) result: WidgetSchema = session.query(Widget).get(yin.widget_id) assert result.name == "New Widget name"
async def test_delete_by_id(session: Session): # noqa yin: FizzSchema = FizzSchema(fizz_id=1, name="Yin", purpose="thing 1") yang: FizzSchema = FizzSchema(fizz_id=2, name="Yang", purpose="thing 2") yin_orm = Fizz(**yin.dict()) yang_orm = Fizz(**yang.dict()) session.add(yin_orm) session.add(yang_orm) session.commit() await FizzService.delete_by_id(1, session) session.commit() results: List[Fizz] = session.query(Fizz).all() assert len(results) == 1 assert yin_orm not in results and yang_orm in results
async def test_delete_by_id(session: Session): # noqa yin: WidgetSchema = WidgetSchema(widget_id=1, name="Yin", purpose="thing 1") yang: WidgetSchema = WidgetSchema(widget_id=2, name="Yang", purpose="thing 2") yin_orm = Widget(**yin.dict()) yang_orm = Widget(**yang.dict()) session.add(yin_orm) session.add(yang_orm) session.commit() await WidgetService.delete_by_id(1, session) session.commit() results: List[Widget] = session.query(Widget).all() assert len(results) == 1 assert yin_orm not in results and yang_orm in results
def test_Fizz_retrieve(fizz: Fizz, session: Session): # noqa session.add(fizz) session.commit() s = session.query(Fizz).first() assert s.__dict__ == fizz.__dict__
def test_Widget_retrieve(widget: Widget, session: Session): # noqa session.add(widget) session.commit() s = session.query(Widget).first() assert s.__dict__ == widget.__dict__