Added unit test.

This commit is contained in:
Antoine Nguyen
2021-06-08 08:36:16 +02:00
parent 575316f9af
commit 6a8dfe49a6
4 changed files with 59 additions and 8 deletions
+10
View File
@@ -81,6 +81,16 @@ class AlarmFactory(factory.django.DjangoModelFactory):
model = models.Alarm
class MXRecordFactory(factory.django.DjangoModelFactory):
"""Factory for MXRecord model."""
domain = factory.SubFactory(DomainFactory)
address = "127.0.0.1"
class Meta:
model = models.MXRecord
def populate_database():
"""Create test data.
+5 -5
View File
@@ -188,27 +188,27 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
else:
return "success"
@cached_property
@property
def spf_record(self):
"""Return SPF record."""
return self.dnsrecord_set.filter(type="spf").first()
@cached_property
@property
def dkim_record(self):
"""Return DKIM record."""
return self.dnsrecord_set.filter(type="dkim").first()
@cached_property
@property
def dmarc_record(self):
"""Return DMARC record."""
return self.dnsrecord_set.filter(type="dmarc").first()
@cached_property
@property
def autoconfig_record(self):
"""Return autoconfig record."""
return self.dnsrecord_set.filter(type="autoconfig").first()
@cached_property
@property
def autodiscover_record(self):
"""Return autodiscover record."""
return self.dnsrecord_set.filter(type="autodiscover").first()
-2
View File
@@ -4,7 +4,6 @@ import datetime
from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from modoboa.parameters import tools as param_tools
@@ -52,7 +51,6 @@ class MXRecordManager(models.Manager):
yield record
@python_2_unicode_compatible
class MXRecord(models.Model):
"""A model used to store MX records for Domain."""