async def test_get_all(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")
    session.add(Fizz(**yin.dict()))
    session.add(Fizz(**yang.dict()))
    session.commit()

    results: List[FizzSchema] = await FizzService.get_all(session)

    assert len(results) == 2
    assert yin in results and yang in results
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"
Beispiel #3
0
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"
Beispiel #4
0
async def test_get_all(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")
    session.add(Widget(**yin.dict()))
    session.add(Widget(**yang.dict()))
    session.commit()

    results: List[WidgetSchema] = await WidgetService.get_all(session)

    assert len(results) == 2
    assert yin in results and yang in results
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
Beispiel #6
0
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
Beispiel #7
0
def test_Fizz_retrieve(fizz: Fizz, session: Session):  # noqa
    session.add(fizz)
    session.commit()
    s = session.query(Fizz).first()
    assert s.__dict__ == fizz.__dict__
Beispiel #8
0
def test_Widget_retrieve(widget: Widget, session: Session):  # noqa
    session.add(widget)
    session.commit()
    s = session.query(Widget).first()
    assert s.__dict__ == widget.__dict__