feat: added users app
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class TestUsers(TestCase):
|
||||
|
||||
def test_create_user(self):
|
||||
User.objects.create_user({
|
||||
'username': 'user 1',
|
||||
'password': 'password1'
|
||||
})
|
||||
User.objects.all().count() == 1
|
||||
|
||||
def test_new_user_invalid_username(self):
|
||||
"""Test creating user with no username raises error"""
|
||||
with pytest.raises(ValueError):
|
||||
User.objects.create_user(None, 'test123')
|
||||
|
||||
def test_create_new_superuser(self):
|
||||
"""Test creating a new superuser"""
|
||||
# Creation with standard method
|
||||
user = User.objects.create_superuser(
|
||||
'testsuperuser@adminemail.com',
|
||||
'testadmin123'
|
||||
)
|
||||
assert user.is_superuser
|
||||
assert user.is_staff
|
||||
|
||||
def test_create_group(self):
|
||||
Group.objects.create(name='Group1')
|
||||
assert Group.objects.count() == 1
|
||||
Reference in New Issue
Block a user