Esempio n. 1
0
async def _():
    repository = FakeUsersRepository(
        users=[User(email="*****@*****.**", date_joined=datetime.utcnow())])

    with raises(EmailAlreadyUsedError):
        await register(
            RegisterInputModel(email="*****@*****.**", password="******"),
            users_repository=repository,
        )
Esempio n. 2
0
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
Esempio n. 3
0
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")
Esempio n. 4
0
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