add model tests
This commit is contained in:
parent
7e49bd3039
commit
b044fe2dd9
1 changed files with 28 additions and 0 deletions
|
@ -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')
|
Loading…
Reference in a new issue