Spaces:
Running
on
Zero
Running
on
Zero
import pytest | |
from app.crud import CRUD | |
from app.models import User | |
def crud(): | |
return CRUD('postgresql://user:password@localhost/dbname') | |
def test_create_user(crud): | |
user = crud.create_user('Jane Doe', '[email protected]') | |
assert user.name == 'Jane Doe' | |
assert user.email == '[email protected]' | |
def test_read_user(crud): | |
user = crud.create_user('Jane Doe', '[email protected]') | |
read_user = crud.read_user(user.id) | |
assert read_user.name == 'Jane Doe' | |
assert read_user.email == '[email protected]' | |
def test_update_user(crud): | |
user = crud.create_user('Jane Doe', '[email protected]') | |
updated_user = crud.update_user(user.id, 'Jane Doe Updated', '[email protected]') | |
assert updated_user.name == 'Jane Doe Updated' | |
assert updated_user.email == '[email protected]' | |
def test_delete_user(crud): | |
user = crud.create_user('Jane Doe', '[email protected]') | |
assert crud.delete_user(user.id) |