Spaces:
Running
on
Zero
Running
on
Zero
File size: 984 Bytes
185f702 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import pytest
from app.crud import CRUD
from app.models import User
@pytest.fixture
def crud():
return CRUD('postgresql://user:password@localhost/dbname')
def test_create_user(crud):
user = crud.create_user('Jane Doe', 'janedoe@example.com')
assert user.name == 'Jane Doe'
assert user.email == 'janedoe@example.com'
def test_read_user(crud):
user = crud.create_user('Jane Doe', 'janedoe@example.com')
read_user = crud.read_user(user.id)
assert read_user.name == 'Jane Doe'
assert read_user.email == 'janedoe@example.com'
def test_update_user(crud):
user = crud.create_user('Jane Doe', 'janedoe@example.com')
updated_user = crud.update_user(user.id, 'Jane Doe Updated', 'janedoeupdated@example.com')
assert updated_user.name == 'Jane Doe Updated'
assert updated_user.email == 'janedoeupdated@example.com'
def test_delete_user(crud):
user = crud.create_user('Jane Doe', 'janedoe@example.com')
assert crud.delete_user(user.id) |