Skip to content

Commit

Permalink
Added missing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
simlist committed Jul 10, 2023
1 parent fece0b0 commit 865eebf
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions tests/test_emailuser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import pytest
from pytest import mark, raises
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APIClient, APITestCase

from emailuser.models import EmailUser


pytestmark = mark.django_db

EMAIL = 'me@example.com'
NAME = 'Foo Bar'
PASSWORD = 'MYPASSWORD'
Expand Down Expand Up @@ -109,4 +112,34 @@ def test_email_lowercased(self):
)
user = EmailUser.objects.get(email='upper@example.com')
self.assertEqual(user.name, NAME + '2')



def test_str(self):
name = 'Me or You'
user = EmailUser.objects.create_user(
name=name,
email='you@example.com',
password='bad_password'
)
self.assertEqual(user.get_full_name(), name)
self.assertEqual(user.get_short_name(), name)

def test_manager_errors():
with raises(ValueError):
EmailUser.objects.create_user(
name='',
email='me2@gmail.com',
password='badPassword'
)
with raises(ValueError):
EmailUser.objects.create_user(
name='A Name',
email='',
password='badPassword'
)
with raises(ValueError):
EmailUser.objects.create_superuser(
name='A Name',
email='anotheremail@example.com',
password=''
)

0 comments on commit 865eebf

Please sign in to comment.