コード例 #1
0
import uuid
import pytest

from src.domains.users.services.create_user import CreateUser
from src.domains.users.services.update_user import UpdateUser
from src.domains.users.repository.fake_users_repository import (
    FakeUsersRepository)
from src.exceptions.user_exception import UserException

users_repository = FakeUsersRepository()


@pytest.fixture
def update_user():
    users_repository.users = []
    create_user_service = CreateUser(users_repository)
    update_user_service = UpdateUser(users_repository)

    created_user = create_user_service.run(name='test', email='*****@*****.**')

    return (update_user_service, created_user)


def test_should_update_and_return_user(update_user):
    update_user_service, created_user = update_user
    user = update_user_service.run(
        user_id=created_user.id,
        name='test2',
        email='*****@*****.**',
    )
コード例 #2
0
def create_user_service():
    return CreateUser(FakeUsersRepository())