neo-todo-api/backend/tests/models/test_member.py
minhtrannhat c641ddd47d
Feat(API): Database schema and models defined
- Wrote tests for database migrations and populate with test data
2022-12-23 20:07:36 -05:00

18 lines
706 B
Python

import pytest
from asyncpg.exceptions import UniqueViolationError # type: ignore
from quart_db import Connection
from backend.models.member import insert_member, select_member_by_email
async def test_insert_member(connection: Connection) -> None:
await insert_member(connection, "casing@todo.minhtrannhat.com", "")
with pytest.raises(UniqueViolationError):
await insert_member(connection, "Casing@todo.minhtrannhat.com", "")
async def test_select_member_by_email(connection: Connection) -> None:
await insert_member(connection, "casing@todo.minhtrannhat.com", "")
member = await select_member_by_email(connection, "Casing@todo.minhtrannhat.com")
assert member is not None