Improve DNS table models
This commit adds Meta information and __str__ methods to all DNS table models. The new methods are now covered with new tests. The new constants DNS_DOMAIN_METADATA_KINDS and DNS_TSIG_KEY_ALGORITHMS are defined and used in the DNSDomainMetadata and DNSTSIGKey models. A matching database schema migration is added. Addresses #17
This commit is contained in:
parent
1df2534cf3
commit
c058cc7b1d
3 changed files with 193 additions and 7 deletions
|
@ -10,9 +10,16 @@ from django.test import TestCase
|
|||
from django.contrib.auth import get_user_model
|
||||
|
||||
from domains.models import (
|
||||
DNSComment,
|
||||
DNSCryptoKey,
|
||||
DNSDomain,
|
||||
DNSDomainMetadata,
|
||||
DNSRecord,
|
||||
DNSSupermaster,
|
||||
DNSTSIGKey,
|
||||
DomainBase,
|
||||
MailDomain,
|
||||
HostingDomain,
|
||||
MailDomain,
|
||||
)
|
||||
from hostingpackages.models import (
|
||||
CustomerHostingPackage,
|
||||
|
@ -27,14 +34,14 @@ TEST_USER = 'test'
|
|||
|
||||
class DomainBaseTest(TestCase):
|
||||
|
||||
def test__str__(self):
|
||||
def test___str__(self):
|
||||
db = DomainBase(domain='test')
|
||||
self.assertEqual(str(db), 'test')
|
||||
|
||||
|
||||
class MailDomainTest(TestCase):
|
||||
|
||||
def test__str__(self):
|
||||
def test___str__(self):
|
||||
md = MailDomain.objects.create(domain='example.org')
|
||||
self.assertEqual(str(md), 'example.org')
|
||||
|
||||
|
@ -77,8 +84,65 @@ class HostingDomainManagerTest(TestCase):
|
|||
self.assertIsNotNone(hostingdomain)
|
||||
self.assertTrue(hostingdomain.customer, package.customer)
|
||||
|
||||
|
||||
class HostingDomainTest(TestCase):
|
||||
|
||||
def test__str__(self):
|
||||
def test___str__(self):
|
||||
hostingdomain = HostingDomain(domain='test')
|
||||
self.assertEqual(str(hostingdomain), 'test')
|
||||
|
||||
|
||||
class DNSDomainTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnsdomain = DNSDomain(domain='test')
|
||||
self.assertEqual(str(dnsdomain), 'test')
|
||||
|
||||
|
||||
class DNSRecordTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnsrecord = DNSRecord(
|
||||
name='localhost', recordtype='A', content='127.0.0.1')
|
||||
self.assertEqual(str(dnsrecord), 'localhost IN A 127.0.0.1')
|
||||
|
||||
|
||||
class DNSSupermasterTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnssupermaster = DNSSupermaster(
|
||||
ip='127.0.0.1', nameserver='dns.example.org')
|
||||
self.assertEqual(str(dnssupermaster), '127.0.0.1 dns.example.org')
|
||||
|
||||
|
||||
class DNSCommentTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnscomment = DNSComment(
|
||||
name='localhost', commenttype='A', comment='good stuff')
|
||||
self.assertEqual(str(dnscomment), 'localhost IN A: good stuff')
|
||||
|
||||
|
||||
class DNSDomainMetadataTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnsdomain = DNSDomain(domain='test')
|
||||
dnsdomainmetadata = DNSDomainMetadata(
|
||||
domain=dnsdomain, kind='SOA-EDIT', content='INCEPTION')
|
||||
self.assertEqual(str(dnsdomainmetadata), 'test SOA-EDIT INCEPTION')
|
||||
|
||||
|
||||
class DNSCryptoKeyTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnsdomain = DNSDomain(domain='test')
|
||||
dnscryptokey = DNSCryptoKey(domain=dnsdomain, content='testvalue')
|
||||
self.assertEqual(str(dnscryptokey), 'test testvalue')
|
||||
|
||||
|
||||
class DNSTSIGKeyTest(TestCase):
|
||||
|
||||
def test___str__(self):
|
||||
dnstsigkey = DNSTSIGKey(
|
||||
name='testkey', algorithm='hmac-md5', secret='dummykey')
|
||||
self.assertEqual(str(dnstsigkey), 'testkey hmac-md5 XXXX')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue