<gh_stars>0
from django.test import TestCase
from django.contrib.auth import get_user_model


class ModelTests(TestCase):
    def test_create_user_with_email_sucessful(self):
        """ Text creating a new user with email is successful """
        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_new_user_email_normalized(self):
        """ Test user email is normalized """
        # email = '<EMAIL>'
        email = '<EMAIL>'
        user = get_user_model().objects.create_user(email, 'empire123')

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

    def test_new_user_invalid_email(self):
        """ Test creating new user without email raises error value akash """
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(None, 'empire123')
            # get_user_model().objects.create_user('<EMAIL>', 'empire123')

    def test_new_superuser(self):
        """ Test creating new Super User """
        user = get_user_model().objects.create_superuser('<EMAIL>', 'test123')
        self.assertTrue(user.is_staff)
        self.assertTrue(user.is_superuser)

from django.test import TestCase
from django.contrib.auth import get_user_model


class ModelTests(TestCase):
    def test_create_user_with_email_sucessful(self):
        """ Text creating a new user with email is successful """
        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_new_user_email_normalized(self):
        """ Test user email is normalized """
        # email = '<EMAIL>'
        email = '<EMAIL>'
        user = get_user_model().objects.create_user(email, 'empire123')

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

    def test_new_user_invalid_email(self):
        """ Test creating new user without email raises error value akash """
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(None, 'empire123')
            # get_user_model().objects.create_user('<EMAIL>', 'empire123')

    def test_new_superuser(self):
        """ Test creating new Super User """
        user = get_user_model().objects.create_superuser('<EMAIL>', 'test123')
        self.assertTrue(user.is_staff)
        self.assertTrue(user.is_superuser)
Text creating a new user with email is successful Test user email is normalized # email = '<EMAIL>' Test creating new user without email raises error value akash # get_user_model().objects.create_user('<EMAIL>', 'empire123') Test creating new Super User