mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Testing of Zone and Record name/decoded_name handling
This commit is contained in:
@@ -11,6 +11,7 @@ from __future__ import (
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.idna import idna_encode
|
||||
from octodns.record import (
|
||||
ARecord,
|
||||
AaaaRecord,
|
||||
@@ -83,6 +84,18 @@ class TestRecord(TestCase):
|
||||
)
|
||||
self.assertEqual('mixedcase', record.name)
|
||||
|
||||
def test_utf8(self):
|
||||
zone = Zone('natación.mx.', [])
|
||||
utf8 = 'niño'
|
||||
encoded = idna_encode(utf8)
|
||||
record = ARecord(
|
||||
zone, utf8, {'ttl': 30, 'type': 'A', 'value': '1.2.3.4'}
|
||||
)
|
||||
self.assertEqual(encoded, record.name)
|
||||
self.assertEqual(utf8, record.decoded_name)
|
||||
self.assertTrue(f'{encoded}.{zone.name}', record.fqdn)
|
||||
self.assertTrue(f'{utf8}.{zone.decoded_name}', record.decoded_fqdn)
|
||||
|
||||
def test_alias_lowering_value(self):
|
||||
upper_record = AliasRecord(
|
||||
self.zone,
|
||||
|
||||
@@ -11,6 +11,7 @@ from __future__ import (
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.idna import idna_encode
|
||||
from octodns.record import (
|
||||
ARecord,
|
||||
AaaaRecord,
|
||||
@@ -35,6 +36,13 @@ class TestZone(TestCase):
|
||||
zone = Zone('UniT.TEsTs.', [])
|
||||
self.assertEqual('unit.tests.', zone.name)
|
||||
|
||||
def test_utf8(self):
|
||||
utf8 = 'grüßen.de.'
|
||||
encoded = idna_encode(utf8)
|
||||
zone = Zone(utf8, [])
|
||||
self.assertEqual(encoded, zone.name)
|
||||
self.assertEqual(utf8, zone.decoded_name)
|
||||
|
||||
def test_hostname_from_fqdn(self):
|
||||
zone = Zone('unit.tests.', [])
|
||||
for hostname, fqdn in (
|
||||
@@ -46,6 +54,27 @@ class TestZone(TestCase):
|
||||
('foo.bar', 'foo.bar.unit.tests'),
|
||||
('foo.unit.tests', 'foo.unit.tests.unit.tests.'),
|
||||
('foo.unit.tests', 'foo.unit.tests.unit.tests'),
|
||||
('déjà', 'déjà.unit.tests'),
|
||||
('déjà.foo', 'déjà.foo.unit.tests'),
|
||||
('bar.déjà', 'bar.déjà.unit.tests'),
|
||||
('bar.déjà.foo', 'bar.déjà.foo.unit.tests'),
|
||||
):
|
||||
self.assertEqual(hostname, zone.hostname_from_fqdn(fqdn))
|
||||
|
||||
zone = Zone('grüßen.de.', [])
|
||||
for hostname, fqdn in (
|
||||
('', 'grüßen.de.'),
|
||||
('', 'grüßen.de'),
|
||||
('foo', 'foo.grüßen.de.'),
|
||||
('foo', 'foo.grüßen.de'),
|
||||
('foo.bar', 'foo.bar.grüßen.de.'),
|
||||
('foo.bar', 'foo.bar.grüßen.de'),
|
||||
('foo.grüßen.de', 'foo.grüßen.de.grüßen.de.'),
|
||||
('foo.grüßen.de', 'foo.grüßen.de.grüßen.de'),
|
||||
('déjà', 'déjà.grüßen.de'),
|
||||
('déjà.foo', 'déjà.foo.grüßen.de'),
|
||||
('bar.déjà', 'bar.déjà.grüßen.de'),
|
||||
('bar.déjà.foo', 'bar.déjà.foo.grüßen.de'),
|
||||
):
|
||||
self.assertEqual(hostname, zone.hostname_from_fqdn(fqdn))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user