<reponame>yetoshimo/my-travel-blog
from django import test as django_tests
from django.contrib.auth import get_user_model

from mytravelblog.accounts.forms import UserLoginForm, EditPasswordForm

UserModel = get_user_model()


class EditPasswordFromTests(django_tests.TestCase):
    def setUp(self):
        self.username = 'testuser'
        self.password1 = '<PASSWORD>'

        self.user = UserModel.objects.create_user(
            username=self.username,
            password=<PASSWORD>,
        )

    def test_form_populates_with_form_control_attribute(self):
        data = {
            'old_password': <PASSWORD>,
            'new_password1': <PASSWORD>,
            'new_password2': <PASSWORD>,
        }
        change_password_form = EditPasswordForm(data=data, user=self.user)
        self.assertTrue(change_password_form.is_valid())
        self.assertEqual('form-control', change_password_form.fields['old_password'].widget.attrs['class'])

from django import test as django_tests
from django.contrib.auth import get_user_model

from mytravelblog.accounts.forms import UserLoginForm, EditPasswordForm

UserModel = get_user_model()


class EditPasswordFromTests(django_tests.TestCase):
    def setUp(self):
        self.username = 'testuser'
        self.password1 = '<PASSWORD>'

        self.user = UserModel.objects.create_user(
            username=self.username,
            password=<PASSWORD>,
        )

    def test_form_populates_with_form_control_attribute(self):
        data = {
            'old_password': <PASSWORD>,
            'new_password1': <PASSWORD>,
            'new_password2': <PASSWORD>,
        }
        change_password_form = EditPasswordForm(data=data, user=self.user)
        self.assertTrue(change_password_form.is_valid())
        self.assertEqual('form-control', change_password_form.fields['old_password'].widget.attrs['class'])