Esempio n. 1
0
def test_email_error_msg(fake: Faker, user: User, client: Client):
    """Assert email can't be change using wrong password """
    user.set_password('password')
    user.save()
    client.force_login(user)
    resp = client.post(reverse('core:profile_email'), {
        'email': fake.email(),
        'current_password': '******'
    })
    dj_assert_contains(resp, 'Senha Inválida')
Esempio n. 2
0
def test_edit_email(django_user_model, fake: Faker, user: User,
                    client: Client):
    password = '******'
    user.set_password(password)
    user.save()
    client.force_login(user)
    email = fake.email()
    client.post(reverse('core:profile_email'), {
        'email': email,
        'current_password': password
    })
    assert email == django_user_model.objects.filter(pk=user.pk).get().email
Esempio n. 3
0
def test_edit_password(django_user_model, user: User, client: Client):
    old_password = '******'
    user.set_password(old_password)
    user.save()
    client.force_login(user)
    new_password = '******'
    client.post(reverse('core:profile_password'), {
        'old_password': old_password,
        'new_password1': new_password,
        'new_password2': new_password,
    },
                secure=True)
    user = django_user_model.objects.filter(pk=user.pk).get()
    assert user.check_password(new_password)
Esempio n. 4
0
def test_not_edit_email_wrong_password(django_user_model, fake: Faker,
                                       user: User, client: Client):
    """Assert email can't be change using wrong password """
    user.set_password('password')
    user.save()
    client.force_login(user)
    old_email = user.email
    resp = client.post(reverse('core:profile_email'), {
        'email': fake.email(),
        'current_password': '******'
    })
    assert old_email == django_user_model.objects.filter(
        pk=user.pk).get().email
    assert 200 == resp.status_code