2014-05-24 13:56:45 +02:00
|
|
|
from django.test import TestCase
|
2014-06-01 18:29:41 +02:00
|
|
|
from django.test.utils import override_settings
|
|
|
|
|
2014-05-24 13:56:45 +02:00
|
|
|
from passlib.hash import sha512_crypt
|
|
|
|
|
2014-05-25 15:17:08 +02:00
|
|
|
from domains.models import MailDomain
|
2014-05-25 14:53:58 +02:00
|
|
|
from osusers.models import User
|
2014-06-01 18:29:41 +02:00
|
|
|
|
2014-05-24 13:56:45 +02:00
|
|
|
from managemails.models import (
|
|
|
|
MailAddress,
|
|
|
|
Mailbox,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-06-01 18:29:41 +02:00
|
|
|
@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):
|
2014-05-25 14:53:58 +02:00
|
|
|
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))
|
|
|
|
|
2014-06-01 18:29:41 +02:00
|
|
|
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')
|