<filename>app/core/tests/test_models.py
from django.test import TestCase
from django.contrib.auth import get_user_model


class ModelTests(TestCase):

    def test_create_user_model(self):
        """Test for creating user model"""
        email = "<EMAIL>"
        password = "<PASSWORD>"
        user = get_user_model().objects.create_user(
            email=email, password=password
        )

        self.assertEqual(user.email, email)
        self.assertTrue(user.check_password(password))

    def test_create_user_email_normalized(self):
        """Test for create user with normailized email"""
        email = '<EMAIL>'
        user = get_user_model().objects.create_user(
            email=email, password='<PASSWORD>'
        )

        self.assertEqual(user.email, email.lower())

    def test_create_user_with_no_email(self):
        """Test for create user without email is invalid"""
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(None, 'test')

    def test_create_superuser(self):
        """Test for creating superuser"""
        email = '<EMAIL>'
        user = get_user_model().objects.create_superuser(
            email=email,
            password='<PASSWORD>'
        )
        self.assertTrue(user.is_superuser)
        self.assertTrue(user.is_staff)

<filename>app/core/tests/test_models.py
from django.test import TestCase
from django.contrib.auth import get_user_model


class ModelTests(TestCase):

    def test_create_user_model(self):
        """Test for creating user model"""
        email = "<EMAIL>"
        password = "<PASSWORD>"
        user = get_user_model().objects.create_user(
            email=email, password=password
        )

        self.assertEqual(user.email, email)
        self.assertTrue(user.check_password(password))

    def test_create_user_email_normalized(self):
        """Test for create user with normailized email"""
        email = '<EMAIL>'
        user = get_user_model().objects.create_user(
            email=email, password='<PASSWORD>'
        )

        self.assertEqual(user.email, email.lower())

    def test_create_user_with_no_email(self):
        """Test for create user without email is invalid"""
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(None, 'test')

    def test_create_superuser(self):
        """Test for creating superuser"""
        email = '<EMAIL>'
        user = get_user_model().objects.create_superuser(
            email=email,
            password='<PASSWORD>'
        )
        self.assertTrue(user.is_superuser)
        self.assertTrue(user.is_staff)

Test for creating user model Test for create user with normailized email Test for create user without email is invalid Test for creating superuser