async def _(): repository = FakeUsersRepository( users=[User(email="*****@*****.**", date_joined=datetime.utcnow())]) with raises(EmailAlreadyUsedError): await register( RegisterInputModel(email="*****@*****.**", password="******"), users_repository=repository, )
async def _(): with raises(pydantic.ValidationError) as exc: RegisterInputModel(email="", password="******") errors = exc.raised.errors() assert len(errors) == 1 assert { "loc": ("email", ), "msg": "value is not a valid email address", "type": "value_error.email", } in errors
async def _(): repository = FakeUsersRepository(users=[]) user = await register( RegisterInputModel(email="*****@*****.**", password="******"), users_repository=repository, ) assert repository.committed assert user.id is not None assert user.email == "*****@*****.**" assert user.check_password("hello_world")
async def _(): with raises(pydantic.ValidationError) as exc: RegisterInputModel(email="*****@*****.**", password="") errors = exc.raised.errors() assert len(errors) == 1 assert { "loc": ("password", ), "msg": "ensure this value has at least 8 characters", "type": "value_error.any_str.min_length", "ctx": { "limit_value": 8 }, } in errors