add model tests

This commit is contained in:
Jan Dittberner 2014-05-24 13:56:45 +02:00
parent 7e49bd3039
commit b044fe2dd9

View file

@ -0,0 +1,28 @@
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')