--- a/pvl/hosts/tests.py Wed Feb 25 15:06:28 2015 +0200
+++ b/pvl/hosts/tests.py Wed Feb 25 15:09:51 2015 +0200
@@ -84,11 +84,7 @@
'ethernet.eth0': 'bar',
})
-class TestForwardZone(unittest.TestCase):
- def setUp(self):
- self.options = Options()
- self.options.add_origin = False
-
+class TestZoneMixin(object):
def assertZoneEquals(self, rrs, expected):
gather = { }
@@ -101,6 +97,12 @@
self.assertDictEqual(gather, expected)
+
+class TestForwardZone(TestZoneMixin, unittest.TestCase):
+ def setUp(self):
+ self.options = Options()
+ self.options.add_origin = False
+
def testResolve(self):
self.assertEquals(zone.resolve(None, None, 'host'), 'host.')
self.assertEquals(zone.resolve(None, 'domain', 'host'), 'host.domain.')
@@ -117,7 +119,7 @@
with self.assertRaises(zone.HostZoneError):
zone.resolve('origin', None, 'host.domain')
- def testHostForwardOutOfOrigin(self):
+ def testHostOutOfOrigin(self):
h = host.Host('host', 'domain', ip=ipaddr.IPAddress('10.0.0.1'))
self.assertZoneEquals(zone.host_forward(h, 'test'), { })
@@ -190,6 +192,15 @@
with self.assertRaises(zone.HostZoneError):
self.assertZoneEquals(zone.host_forward(h, 'domain'), { })
+ def testHostDelegate(self):
+ h = host.Host.build('host', 'example.com',
+ forward = 'host.example.net',
+ )
+
+ self.assertZoneEquals(zone.host_forward(h, 'example.com'), {
+ ('host', 'CNAME'): ['host.example.net.'],
+ })
+
def testHostForwardAlias(self):
h = host.Host.build('host', 'domain',
forward = 'host.example.net',
@@ -201,14 +212,10 @@
('test', 'CNAME'): ['host'],
})
- def testHostDelegateForward(self):
- h = host.Host.build('host', 'example.com',
- forward = 'host.example.net',
- )
-
- self.assertZoneEquals(zone.host_forward(h, 'example.com'), {
- ('host', 'CNAME'): ['host.example.net.'],
- })
+class TestReverseZone(TestZoneMixin, unittest.TestCase):
+ def setUp(self):
+ self.options = Options()
+ self.options.unknown_host = False
def testHostDelegate(self):
h = host.Host.build('host', 'example.com',
@@ -230,5 +237,6 @@
})
+
if __name__ == '__main__':
unittest.main()