gva/gnuviechadmin/managemails/tests/test_models.py

29 lines
805 B
Python
Raw Normal View History

2014-05-24 13:56:45 +02:00
from django.test import TestCase
from passlib.hash import sha512_crypt
from managemails.models import (
MailAddress,
MailDomain,
Mailbox,
)
class MailDomainTest(TestCase):
def test__str__(self):
md = MailDomain.objects.create(domain='example.org')
self.assertEqual(str(md), 'example.org')
class MailboxTest(TestCase):
def test_set_password(self):
mb = Mailbox.objects.create(username='test', uid=1000, gid=1000)
mb.set_password('test')
self.assertTrue(sha512_crypt.verify('test', mb.password))
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')