24 lines
723 B
Python
24 lines
723 B
Python
from django.test import TestCase
|
|
from passlib.hash import sha512_crypt
|
|
|
|
from domains.models import MailDomain
|
|
from osusers.models import User
|
|
from managemails.models import (
|
|
MailAddress,
|
|
Mailbox,
|
|
)
|
|
|
|
|
|
class MailboxTest(TestCase):
|
|
def test_set_password(self):
|
|
user = User.objects.create_user()
|
|
mb = Mailbox.objects.create(username='test', osuser=user)
|
|
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')
|