def test_rename_domain(self): """Test domain rename.""" domain = admin_factories.DomainFactory(name="domain.test") domain.name = "domain1.test" domain.save() name = "@{}".format(domain.name) self.assertTrue(models.Users.objects.filter(email=name).exists()) self.assertTrue( models.Policy.objects.filter(policy_name=name).exists()) # Now from form self.client.force_login(self.admin) rdomain = admin_factories.DomainFactory(name="domain.relay", type="relaydomain") rdomain.transport = tr_factories.TransportFactory( pattern=rdomain.name, service="relay", _settings={ "relay_target_host": "external.host.tld", "relay_target_port": "25", "relay_verify_recipients": False }) rdomain.save() values = { "name": "domain2.relay", "quota": rdomain.quota, "default_mailbox_quota": rdomain.default_mailbox_quota, "type": "relaydomain", "enabled": rdomain.enabled, "service": rdomain.transport.service, "relay_target_host": "127.0.0.1", "relay_target_port": 25, } self.ajax_post(reverse("admin:domain_change", args=[rdomain.pk]), values)
def setUpTestData(cls): # NOQA:N802 super(DataMixin, cls).setUpTestData() transport = tr_factories.TransportFactory( pattern="test.com", _settings={ "relay_target_host": "external.host.tld", "relay_target_port": 25, "relay_verify_recipients": False } ) cls.domain1 = admin_factories.DomainFactory( name="test.com", type="relaydomain", transport=transport) transport = tr_factories.TransportFactory( pattern="domain2.test", _settings={ "relay_target_host": "external.host.tld", "relay_target_port": 25, "relay_verify_recipients": True } ) cls.domain2 = admin_factories.DomainFactory( name="test2.com", type="relaydomain", transport=transport)
def setUpTestData(cls): """Create test data.""" super(RelayDomainsTestCase, cls).setUpTestData() admin_factories.populate_database() cls.dom = admin_factories.DomainFactory(name="relaydomain.tld", type="relaydomain") cls.transport = tr_factories.TransportFactory( pattern=cls.dom.name, _settings={ "relay_target_host": "external.host.tld", "relay_target_port": "25", "relay_verify_recipients": False }) admin_factories.DomainAliasFactory(name="relaydomainalias.tld", target=cls.dom) admin_factories.MailboxFactory(domain=cls.dom, address="local", user__username="******", user__groups=("SimpleUsers", ))