<filename>WebSearchableEquipmentDatabase/accounts/tests/test_forms.py
from django.test import SimpleTestCase
from django.test import TestCase
from django.urls import reverse

from accounts.forms import AccountCreationForm


class TestViews(TestCase):

    def test_accounts_login_is_resolved(self):
        response = self.client.get(reverse('login'))
        self.assertEqual(response.status_code, 200)

    def test_accounts_dashboard_is_resolved(self):
        response = self.client.get(reverse('home'))
        self.assertEqual(response.status_code, 200)


class AccountFormTest(TestCase):
    def test_account_form_valid_email(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertTrue(form.is_valid())

    def test_account_form_invalid_root_email(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_base_email(self):
        email = "@dev.com"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_no_password1(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': '', 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_no_password2(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': ''})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_diff_passwords(self):
        email = "<EMAIL>"
        password1 = "<PASSWORD>"
        password2 = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': <PASSWORD>, 'password2': <PASSWORD>})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_diff_passwords(self):
        email = "<EMAIL>"
        password1 = "<PASSWORD>"
        password2 = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': <PASSWORD>, 'password2': <PASSWORD>})
        self.assertFalse(form.is_valid())

<filename>WebSearchableEquipmentDatabase/accounts/tests/test_forms.py
from django.test import SimpleTestCase
from django.test import TestCase
from django.urls import reverse

from accounts.forms import AccountCreationForm


class TestViews(TestCase):

    def test_accounts_login_is_resolved(self):
        response = self.client.get(reverse('login'))
        self.assertEqual(response.status_code, 200)

    def test_accounts_dashboard_is_resolved(self):
        response = self.client.get(reverse('home'))
        self.assertEqual(response.status_code, 200)


class AccountFormTest(TestCase):
    def test_account_form_valid_email(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertTrue(form.is_valid())

    def test_account_form_invalid_root_email(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_base_email(self):
        email = "@dev.com"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_no_password1(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': '', 'password2': password})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_no_password2(self):
        email = "<EMAIL>"
        password = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': password, 'password2': ''})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_diff_passwords(self):
        email = "<EMAIL>"
        password1 = "<PASSWORD>"
        password2 = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': <PASSWORD>, 'password2': <PASSWORD>})
        self.assertFalse(form.is_valid())

    def test_account_form_invalid_diff_passwords(self):
        email = "<EMAIL>"
        password1 = "<PASSWORD>"
        password2 = "<PASSWORD>"
        form = AccountCreationForm(data={'email': email, 'password1': <PASSWORD>, 'password2': <PASSWORD>})
        self.assertFalse(form.is_valid())
