gva/gnuviechadmin/managemails/tests/test_models.py

39 lines
1.1 KiB
Python
Raw Normal View History

2014-05-24 13:56:45 +02:00
from django.test import TestCase
from django.test.utils import override_settings
2014-05-24 13:56:45 +02:00
from passlib.hash import sha512_crypt
from domains.models import MailDomain
from osusers.models import User
2014-05-24 13:56:45 +02:00
from managemails.models import (
MailAddress,
Mailbox,
)
@override_settings(
CELERY_ALWAYS_EAGER=True,
CELERY_CACHE_BACKEND='memory',
BROKER_BACKEND='memory'
)
2014-05-24 13:56:45 +02:00
class MailboxTest(TestCase):
def test_set_password(self):
user = User.objects.create_user()
mb = Mailbox.objects.create(username='test', osuser=user)
2014-05-24 13:56:45 +02:00
mb.set_password('test')
self.assertTrue(sha512_crypt.verify('test', mb.password))
def test___str__(self):
user = User.objects.create_user()
mb = Mailbox.objects.create(username='test', osuser=user)
mb.set_password('test')
self.assertEqual(str(mb), 'test')
2014-05-24 13:56:45 +02:00
class MailAddressTest(TestCase):
def test__str__(self):
md = MailDomain.objects.create(domain='example.org')
ma = MailAddress.objects.create(localpart='test', domain=md)
self.assertEqual(str(ma), 'test@example.org')