from django.test import TestCase

from accounts.forms import RegistrationForm


class TestMixing(object):
    def setUp(self):
        self.data = {
            'username': 'test',
            'email': '<EMAIL>',
            'password1': <PASSWORD>',
            'password2': <PASSWORD>'
        }


class RegistrationFormTest(TestMixing, TestCase):
    def test_valid_data(self):
        form = RegistrationForm(data=self.data)

        self.assertTrue(form.is_valid())

    def test_with_blank_data(self):
        form = RegistrationForm(data={})

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors, {
            'username': ['This field is required.'],
            'email': ['This field is required.'],
            'password1': ['<PASSWORD>.'],
            'password2': ['<PASSWORD>.'],
        })

from django.test import TestCase

from accounts.forms import RegistrationForm


class TestMixing(object):
    def setUp(self):
        self.data = {
            'username': 'test',
            'email': '<EMAIL>',
            'password1': <PASSWORD>',
            'password2': <PASSWORD>'
        }


class RegistrationFormTest(TestMixing, TestCase):
    def test_valid_data(self):
        form = RegistrationForm(data=self.data)

        self.assertTrue(form.is_valid())

    def test_with_blank_data(self):
        form = RegistrationForm(data={})

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors, {
            'username': ['This field is required.'],
            'email': ['This field is required.'],
            'password1': ['<PASSWORD>.'],
            'password2': ['<PASSWORD>.'],
        })
