2015-11-28 15:07:34 +01:00
|
|
|
"""
|
|
|
|
This module contains tests for :py:mod:`managemails.models`
|
|
|
|
"""
|
2019-01-30 21:27:25 +01:00
|
|
|
from unittest.mock import patch
|
2015-11-28 15:07:34 +01:00
|
|
|
|
2023-02-18 22:46:48 +01:00
|
|
|
from django.contrib.auth import get_user_model
|
2015-11-28 15:07:34 +01:00
|
|
|
from django.test import TestCase, TransactionTestCase
|
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
|
2019-01-30 21:27:25 +01:00
|
|
|
from managemails.models import MailAddress, Mailbox
|
2023-02-18 22:46:48 +01:00
|
|
|
from osusers.models import User
|
2014-05-24 13:56:45 +02:00
|
|
|
|
2015-02-01 20:12:23 +01:00
|
|
|
Customer = get_user_model()
|
|
|
|
|
2014-05-24 13:56:45 +02:00
|
|
|
|
2014-06-01 18:29:41 +02:00
|
|
|
@override_settings(
|
2019-01-30 21:27:25 +01:00
|
|
|
CELERY_ALWAYS_EAGER=True, CELERY_CACHE_BACKEND="memory", BROKER_BACKEND="memory"
|
2014-06-01 18:29:41 +02:00
|
|
|
)
|
2014-05-24 13:56:45 +02:00
|
|
|
class MailboxTest(TestCase):
|
2015-02-01 20:12:23 +01:00
|
|
|
def setUp(self):
|
|
|
|
super(MailboxTest, self).setUp()
|
2019-01-30 21:27:25 +01:00
|
|
|
self.customer = Customer.objects.create_user("test")
|
2015-02-01 20:12:23 +01:00
|
|
|
|
2014-05-24 13:56:45 +02:00
|
|
|
def test_set_password(self):
|
2015-02-01 20:12:23 +01:00
|
|
|
user = User.objects.create_user(self.customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
mb = Mailbox.objects.create(username="test", osuser=user)
|
|
|
|
mb.set_password("test")
|
|
|
|
self.assertTrue(sha512_crypt.verify("test", mb.password))
|
2014-05-24 13:56:45 +02:00
|
|
|
|
2014-06-01 18:29:41 +02:00
|
|
|
def test___str__(self):
|
2015-02-01 20:12:23 +01:00
|
|
|
user = User.objects.create_user(self.customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
mb = Mailbox.objects.create(username="test", osuser=user)
|
|
|
|
mb.set_password("test")
|
|
|
|
self.assertEqual(str(mb), "test")
|
2014-06-01 18:29:41 +02:00
|
|
|
|
2019-01-30 21:27:25 +01:00
|
|
|
@patch("managemails.models.create_file_mailbox")
|
2015-11-28 15:07:34 +01:00
|
|
|
def test_save(self, create_file_mailbox_task):
|
|
|
|
user = User.objects.create_user(self.customer)
|
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
self.assertIsNotNone(mb.pk)
|
2019-01-30 21:27:25 +01:00
|
|
|
create_file_mailbox_task.delay.assert_called_with(user.username, mb.username)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
2019-01-30 21:27:25 +01:00
|
|
|
@patch("managemails.models.delete_file_mailbox")
|
2015-11-28 15:07:34 +01:00
|
|
|
def test_delete(self, delete_file_mailbox_task):
|
|
|
|
user = User.objects.create_user(self.customer)
|
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
mb.delete()
|
|
|
|
self.assertIsNone(mb.pk)
|
2019-01-30 21:27:25 +01:00
|
|
|
delete_file_mailbox_task.delay.assert_called_with(user.username, mb.username)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_get_mailaddresses(self):
|
|
|
|
user = User.objects.create_user(self.customer)
|
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
address.set_mailbox(mb)
|
|
|
|
mailaddresses = mb.get_mailaddresses()
|
|
|
|
self.assertEqual(len(mailaddresses), 1)
|
|
|
|
self.assertIn(address, mailaddresses)
|
|
|
|
|
|
|
|
|
|
|
|
@override_settings(
|
2019-01-30 21:27:25 +01:00
|
|
|
CELERY_ALWAYS_EAGER=True, CELERY_CACHE_BACKEND="memory", BROKER_BACKEND="memory"
|
2015-11-28 15:07:34 +01:00
|
|
|
)
|
|
|
|
class MailAddressTest(TransactionTestCase):
|
2014-05-24 13:56:45 +02:00
|
|
|
def test__str__(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
self.assertEqual(str(ma), "test@example.org")
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_mailbox_fresh(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb)
|
|
|
|
self.assertIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_mailbox_reassing(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb)
|
|
|
|
mb2 = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb2)
|
|
|
|
self.assertIn(ma, mb2.get_mailaddresses())
|
|
|
|
self.assertNotIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_mailbox_with_forwards(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
2015-11-28 15:07:34 +01:00
|
|
|
ma.set_mailbox(mb)
|
|
|
|
self.assertEqual(ma.mailaddressforward_set.count(), 0)
|
|
|
|
self.assertIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_mailbox_with_unsaved_address(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb)
|
|
|
|
self.assertIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_mailbox_fresh_no_commit(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb, commit=False)
|
|
|
|
self.assertNotIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_mailbox_with_unsaved_address_no_commit(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb, commit=False)
|
|
|
|
self.assertNotIn(ma, mb.get_mailaddresses())
|
|
|
|
|
|
|
|
def test_set_forward_addresses_fresh(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
|
|
|
|
|
|
|
def get_target(maf):
|
|
|
|
return maf.target
|
|
|
|
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertQuerysetEqual(
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_addresses_unsaved(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress(localpart="test", domain=md)
|
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
|
|
|
|
|
|
|
def get_target(maf):
|
|
|
|
return maf.target
|
|
|
|
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertQuerysetEqual(
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_addresses_replace_forwards(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
|
|
|
ma.set_forward_addresses(["test3@example.org"])
|
|
|
|
|
|
|
|
def get_target(maf):
|
|
|
|
return maf.target
|
|
|
|
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertQuerysetEqual(
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.mailaddressforward_set.all(), ["test3@example.org"], get_target
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_addresses_add_forwards(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
|
|
|
ma.set_forward_addresses(["test2@example.org", "test3@example.org"])
|
|
|
|
|
|
|
|
def get_target(maf):
|
|
|
|
return maf.target
|
|
|
|
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertQuerysetEqual(
|
|
|
|
ma.mailaddressforward_set.all(),
|
2019-01-30 21:27:25 +01:00
|
|
|
["test2@example.org", "test3@example.org"],
|
|
|
|
get_target,
|
|
|
|
ordered=False,
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_addresses_replace_mailbox(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
user = User.objects.create_user(customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb)
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.set_forward_addresses(["test2@example.org"])
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertNotIn(ma, mb.get_mailaddresses())
|
2019-01-30 21:27:25 +01:00
|
|
|
|
|
|
|
def get_target(maf):
|
|
|
|
return maf.target
|
|
|
|
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertQuerysetEqual(
|
2019-01-30 21:27:25 +01:00
|
|
|
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_addresses_fresh_no_commit(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
mafwds = ma.set_forward_addresses(["test2@example.org"], commit=False)
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertEqual(ma.mailaddressforward_set.count(), 0)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mafwds[0].target, "test2@example.org")
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_set_forward_address_unsaved_no_commit(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress(localpart="test", domain=md)
|
|
|
|
mafwds = ma.set_forward_addresses(["test2@example.org"], commit=False)
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertEqual(ma.mailaddressforward_set.count(), 0)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mafwds[0].target, "test2@example.org")
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
@override_settings(
|
2019-01-30 21:27:25 +01:00
|
|
|
CELERY_ALWAYS_EAGER=True, CELERY_CACHE_BACKEND="memory", BROKER_BACKEND="memory"
|
2015-11-28 15:07:34 +01:00
|
|
|
)
|
|
|
|
class MailboxManagerTest(TransactionTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(MailboxManagerTest, self).setUp()
|
2019-01-30 21:27:25 +01:00
|
|
|
self.customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
self.user = User.objects.create_user(self.customer)
|
|
|
|
|
|
|
|
def test_get_next_mailbox_name_fresh(self):
|
|
|
|
mailboxname = Mailbox.objects.get_next_mailbox_name(self.user)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mailboxname, "{}p01".format(self.user.username))
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_get_next_mailbox_name_second(self):
|
|
|
|
Mailbox.objects.create_mailbox(self.user)
|
|
|
|
mailboxname = Mailbox.objects.get_next_mailbox_name(self.user)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mailboxname, "{}p02".format(self.user.username))
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_get_next_mailbox_name_gap_detection(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(3)]
|
2015-11-28 15:07:34 +01:00
|
|
|
mailboxes[1].delete()
|
|
|
|
mailboxname = Mailbox.objects.get_next_mailbox_name(self.user)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mailboxname, "{}p02".format(self.user.username))
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_unused_or_own_fresh(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mailboxes = Mailbox.objects.unused_or_own(address, self.user)
|
|
|
|
self.assertQuerysetEqual(mailboxes, [])
|
|
|
|
|
|
|
|
def test_unused_or_own_unassigned(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
2015-11-28 15:07:34 +01:00
|
|
|
assignable = Mailbox.objects.unused_or_own(address, self.user)
|
2023-02-18 22:46:48 +01:00
|
|
|
self.assertQuerysetEqual(
|
|
|
|
assignable, [repr(mb) for mb in mailboxes], transform=repr
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_unused_or_own_assigned(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
2015-11-28 15:07:34 +01:00
|
|
|
address.set_mailbox(mailboxes[0])
|
|
|
|
assignable = Mailbox.objects.unused_or_own(address, self.user)
|
2023-02-18 22:46:48 +01:00
|
|
|
self.assertQuerysetEqual(
|
|
|
|
assignable, [repr(mb) for mb in mailboxes], transform=repr
|
|
|
|
)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_unused_or_own_assigned_other(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
address2 = MailAddress.objects.create(localpart="test2", domain=md)
|
|
|
|
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
2015-11-28 15:07:34 +01:00
|
|
|
address2.set_mailbox(mailboxes[0])
|
|
|
|
assignable = Mailbox.objects.unused_or_own(address, self.user)
|
2023-02-18 22:46:48 +01:00
|
|
|
self.assertQuerysetEqual(assignable, [repr(mailboxes[1])], transform=repr)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_unused_fresh(self):
|
|
|
|
mailboxes = Mailbox.objects.unused(self.user)
|
|
|
|
self.assertQuerysetEqual(mailboxes, [])
|
|
|
|
|
|
|
|
def test_unused_unassigned(self):
|
|
|
|
mailbox = Mailbox.objects.create_mailbox(self.user)
|
|
|
|
mailboxes = Mailbox.objects.unused(self.user)
|
2023-02-18 22:46:48 +01:00
|
|
|
self.assertQuerysetEqual(mailboxes, [repr(mailbox)], transform=repr)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_unused_assigned(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
address = MailAddress.objects.create(localpart="test", domain=md)
|
|
|
|
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
2015-11-28 15:07:34 +01:00
|
|
|
address.set_mailbox(mailboxes[0])
|
|
|
|
assignable = Mailbox.objects.unused(self.user)
|
2023-02-18 22:46:48 +01:00
|
|
|
self.assertQuerysetEqual(assignable, [repr(mailboxes[1])], transform=repr)
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_create_mailbox_no_password(self):
|
|
|
|
mailbox = Mailbox.objects.create_mailbox(self.user)
|
|
|
|
self.assertEqual(mailbox.osuser, self.user)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mailbox.username, "{}p01".format(self.user.username))
|
|
|
|
self.assertEqual(mailbox.password, "")
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test_create_mailbox_with_password(self):
|
2019-01-30 21:27:25 +01:00
|
|
|
mailbox = Mailbox.objects.create_mailbox(self.user, "test")
|
2015-11-28 15:07:34 +01:00
|
|
|
self.assertEqual(mailbox.osuser, self.user)
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual(mailbox.username, "{}p01".format(self.user.username))
|
|
|
|
self.assertTrue(sha512_crypt.verify("test", mailbox.password))
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
@override_settings(
|
2019-01-30 21:27:25 +01:00
|
|
|
CELERY_ALWAYS_EAGER=True, CELERY_CACHE_BACKEND="memory", BROKER_BACKEND="memory"
|
2015-11-28 15:07:34 +01:00
|
|
|
)
|
|
|
|
class MailAddressMailboxTest(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(MailAddressMailboxTest, self).setUp()
|
2019-01-30 21:27:25 +01:00
|
|
|
self.customer = Customer.objects.create_user("test")
|
2015-11-28 15:07:34 +01:00
|
|
|
|
|
|
|
def test___str__(self):
|
|
|
|
user = User.objects.create_user(self.customer)
|
2019-01-30 21:27:25 +01:00
|
|
|
md = MailDomain.objects.create(domain="example.org")
|
|
|
|
ma = MailAddress(localpart="test", domain=md)
|
2015-11-28 15:07:34 +01:00
|
|
|
mb = Mailbox.objects.create_mailbox(user)
|
|
|
|
ma.set_mailbox(mb)
|
|
|
|
self.assertEqual(str(ma.mailaddressmailbox), mb.username)
|