Project Setup
Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla.
Mi tincidunt elit, id quisque ligula ac diam, amet. Vel etiam suspendisse morbi eleifend faucibus eget vestibulum felis. Dictum quis montes, sit sit. Tellus aliquam enim urna, etiam. Mauris posuere vulputate arcu amet, vitae nisi, tellus tincidunt. At feugiat sapien varius id.
1from django.contrib.auth import get_user_model2from django.test import TestCase345class UsersManagersTests(TestCase):67 def test_create_user(self):8 User = get_user_model()9 user = User.objects.create_user(email="normal@user.com", password="foo")10 self.assertEqual(user.email, "normal@user.com")11 self.assertTrue(user.is_active)12 self.assertFalse(user.is_staff)13 self.assertFalse(user.is_superuser)14 try:15 # username is None for the AbstractUser option16 # username does not exist for the AbstractBaseUser option17 self.assertIsNone(user.username)18 except AttributeError:19 pass20 with self.assertRaises(TypeError):21 User.objects.create_user()22 with self.assertRaises(TypeError):23 User.objects.create_user(email="")24 with self.assertRaises(ValueError):25 User.objects.create_user(email="", password="foo")2627 def test_create_superuser(self):28 User = get_user_model()29 admin_user = User.objects.create_superuser(email="super@user.com", password="foo")30 self.assertEqual(admin_user.email, "super@user.com")31 self.assertTrue(admin_user.is_active)32 self.assertTrue(admin_user.is_staff)33 self.assertTrue(admin_user.is_superuser)34 try:35 # username is None for the AbstractUser option36 # username does not exist for the AbstractBaseUser option37 self.assertIsNone(admin_user.username)38 except AttributeError:39 pass40 with self.assertRaises(ValueError):41 User.objects.create_superuser(42 email="super@user.com", password="foo", is_superuser=False)
Tests
Eget quis mi enim, leo lacinia pharetra, semper. Eget in volutpat mollis at volutpat lectus velit, sed auctor. Porttitor fames arcu quis fusce augue enim. Quis at habitant diam at. Suscipit tristique risus, at donec. In turpis vel et quam imperdiet. Ipsum molestie aliquet sodales id est ac volutpat.
Tristique odio senectus nam posuere ornare leo metus, ultricies. Blandit duis ultricies vulputate morbi feugiat cras placerat elit. Aliquam tellus lorem sed ac. Montes, sed mattis pellentesque suscipit accumsan. Cursus viverra aenean magna risus elementum faucibus molestie pellentesque. Arcu ultricies sed mauris vestibulum.
1from django.contrib.auth import get_user_model2from django.test import TestCase345class UsersManagersTests(TestCase):67 def test_create_user(self):8 User = get_user_model()9 user = User.objects.create_user(email="normal@user.com", password="foo")10 self.assertEqual(user.email, "normal@user.com")11 self.assertTrue(user.is_active)12 self.assertFalse(user.is_staff)13 self.assertFalse(user.is_superuser)14 try:15 # username is None for the AbstractUser option16 # username does not exist for the AbstractBaseUser option17 self.assertIsNone(user.username)18 except AttributeError:19 pass20 with self.assertRaises(TypeError):21 User.objects.create_user()22 with self.assertRaises(TypeError):23 User.objects.create_user(email="")24 with self.assertRaises(ValueError):25 User.objects.create_user(email="", password="foo")2627 def test_create_superuser(self):28 User = get_user_model()29 admin_user = User.objects.create_superuser(email="super@user.com", password="foo")30 self.assertEqual(admin_user.email, "super@user.com")31 self.assertTrue(admin_user.is_active)32 self.assertTrue(admin_user.is_staff)33 self.assertTrue(admin_user.is_superuser)34 try:35 # username is None for the AbstractUser option36 # username does not exist for the AbstractBaseUser option37 self.assertIsNone(admin_user.username)38 except AttributeError:39 pass40 with self.assertRaises(ValueError):41 User.objects.create_superuser(42 email="super@user.com", password="foo", is_superuser=False)
Heading 4
Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse.
Image caption goes here
.Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse
Heading 5
Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse.
"Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus."
Heading 5
Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus.
Stay Connected and Share
If you found this post helpful, share it with your friends and subscribe for updates!
Blog
Explore Our Latest Insights
Discover tips and trends in software development.