25 lines
536 B
Python
25 lines
536 B
Python
import pytest
|
|
import pytest_asyncio
|
|
|
|
from fooder.domain.user import User
|
|
|
|
|
|
@pytest.fixture
|
|
def user_password(faker):
|
|
return faker.password()
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def user_factory(ctx):
|
|
async def factory(username, password):
|
|
user = User(username=username)
|
|
user.set_password(password)
|
|
await ctx.repo.user.create(user)
|
|
return user
|
|
|
|
return factory
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def user(faker, user_password, user_factory):
|
|
return await user_factory(faker.name(), user_password)
|