Hi guys im struggling with testcases. 
Can you help me with testcase to this implementation ? 


from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager

# Create your models here.
class AccountManager(BaseUserManager):
def create_user(self, email, first_name, last_name, password=None):
if not email:
raise ValueError('Email address is required')
if not first_name:
raise ValueError('First name is required')
if not last_name:
raise ValueError('Last name is required')

user = self.model(first_name=first_name, last_name=last_name, email=self
.normalize_email(email))
user.set_password(password)
user.save(using=self._db)
return user

def create_superuser(self, email, first_name, last_name, password):
user = self.create_user(
email=self.normalize_email(email),
first_name=first_name,
last_name=last_name,
password=password
)
user.is_admin = True
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user


class Account(AbstractBaseUser):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField(verbose_name='email', max_length=60, unique=True)
date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=
True)
last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
is_admin = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name']

objects = AccountManager()

def __str__(self):
return self.email

def has_perm(self, perm, obj=None):
return self.is_admin

def has_module_perms(self, app_label):
return True

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/118d29b7-2585-45f0-8ce2-6d2b0f30130en%40googlegroups.com.
  • tes... sangeerth sathiskumar
    • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to