pvl/hosts/tests.py
changeset 471 e4b4458d8061
parent 470 ac334a55eebc
child 472 814cc88c531b
--- a/pvl/hosts/tests.py	Wed Feb 25 15:12:55 2015 +0200
+++ b/pvl/hosts/tests.py	Wed Feb 25 15:24:49 2015 +0200
@@ -224,6 +224,37 @@
             ('host', 'A'): ['192.0.2.1'],
             ('test', 'CNAME'): ['host'],
         })
+
+    def testHostLocationDomain(self):
+        h = host.Host.build('host', 'foo.domain',
+                ip          = '192.0.2.1',
+                location    = 'test@bar.domain',
+        )
+
+        self.assertEquals(h.location, ('test', 'bar.domain'))
+
+        self.assertZoneEquals(zone.host_forward(h, 'domain'), {
+            ('host.foo', 'A'): ['192.0.2.1'],
+            ('test.bar', 'CNAME'): ['host.foo'],
+        })
+
+    def testHostLocationDomainOutOfOrigin(self):
+        h = host.Host.build('host', 'foo.domain',
+                ip          = '192.0.2.1',
+                location    = 'test@bar.domain',
+        )
+
+        self.assertEquals(h.location, ('test', 'bar.domain'))
+
+        with self.assertRaises(zone.HostZoneError):
+            self.assertZoneEquals(zone.host_forward(h, 'foo.domain'), {
+                ('host', 'A'): ['192.0.2.1'],
+            })
+        
+        # TODO
+        #self.assertZoneEquals(zone.host_forward(h, 'bar.domain'), {
+        #    ('test', 'CNAME'): ['host.foo'],
+        #})
  
 class TestReverseZone(TestZoneMixin, unittest.TestCase):
     def setUp(self):