Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
wbauth / authentication / tests / 1test_models.py
Size: Mime:
from django.test import TestCase
from django.contrib.auth import get_user_model

class UserCreateTestCase(TestCase):
    '''Create User'''

    fixtures = [
        'ContactLocation.yaml',
        'ContactTelephoneType.yaml',
        'ContactCountry.yaml',
    ]

    def setUp(self):
        pass

    def test_create_user_without_email(self):
        '''Create user without E-Mail'''
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(username='user',email=None,password='123456abc')

    def test_create_user_without_username(self):
        '''Create user without Username'''
        with self.assertRaises(ValueError):
            get_user_model().objects.create_user(username=None,email='a@a.de',password='123456abc')

    def test_create_superuser_with_staff_false(self):
        '''Create superuser with extra_fields staff=False'''
        with self.assertRaises(ValueError):
            get_user_model().objects.create_superuser(username='superuser',email='a@a.de',password='123456abc',is_staff=False)

    def test_create_superuser_with_superuser_false(self):
        '''Create superuser with extra_fields superuser=False'''
        with self.assertRaises(ValueError):
            get_user_model().objects.create_superuser(username='superuser',email='a@a.de',password='123456abc',is_superuser=False)

    def test_create_superuser(self):
        '''Create superuser'''
        get_user_model().objects.create_superuser(username='superuser',email='a@a.de',password='123456abc')

    def tearDown(self):
        pass

class UserTestCase(TestCase):
    '''User'''

    fixtures = [
        'ContactLocation.yaml',
        'ContactTelephoneType.yaml',
        'ContactCountry.yaml',
    ]

    def setUp(self):
        self.user = get_user_model().objects.create_user(username='user',email='a@a.de',password='123456abc', first_name='Max', last_name='Mustermann')

    def test_get_full_name(self):
        '''Get full name'''
        self.assertEqual(self.user.get_full_name(), '%s %s' % (self.user.first_name, self.user.last_name))

    def test_get_short_name(self):
        '''Get short name'''
        self.assertEqual(self.user.get_short_name(), '%s' % (self.user.first_name))