testcases

44 views
Skip to first unread message

sangeerth sathiskumar

unread,
Mar 23, 2021, 1:04:57 PM3/23/21
to Django developers (Contributions to Django itself)

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

Adam Johnson

unread,
Mar 23, 2021, 1:06:47 PM3/23/21
to django-d...@googlegroups.com
Hi!

I think you've found the wrong mailing list for this post. This mailing list is for discussing the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy.

For support, please follow the "Getting Help" page: https://docs.djangoproject.com/en/3.1/faq/help/ . This will help you find people who are willing to support you, and to ask your question in a way that makes it easy for them to answer.

Thanks for your understanding and all the best,

Adam

--
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-develop...@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.


--
Adam
Reply all
Reply to author
Forward
0 new messages