pvl/hosts/tests.py
changeset 474 51983fcda6b1
parent 473 68fd85d850ab
child 477 6ad810c8039c
--- a/pvl/hosts/tests.py	Wed Feb 25 15:40:58 2015 +0200
+++ b/pvl/hosts/tests.py	Wed Feb 25 15:49:11 2015 +0200
@@ -341,6 +341,14 @@
         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.2.1/24'))), {
             ('1', 'PTR'): ['host.domain.'],
         })
+        
+        self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.0.0/16'))), {
+            ('1.2', 'PTR'): ['host.domain.'],
+        })
+        
+        self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.0.0/12'))), {
+            ('1.2.0', 'PTR'): ['host.domain.'],
+        })
 
         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8::/64'))), {
 
@@ -392,6 +400,39 @@
 
         })
 
+    def testHostsConflict(self):
+        hosts = [
+                host.Host.build('foo', 'domain',
+                    ip      = '192.0.2.1',
+                ),
+                host.Host.build('bar', 'domain',
+                    ip      = '192.0.2.1',
+                )
+        ]
+        
+        with self.assertRaises(zone.HostZoneError):
+            self.assertZoneEquals(zone.apply_hosts_reverse(self.options, hosts, ipaddr.IPNetwork('192.0.2.1/24')), { })
+
+    def testHostsGenerateUnknown(self):
+        hosts = [
+                host.Host.build('foo', 'domain',
+                    ip      = '192.0.2.1',
+                ),
+                host.Host.build('bar', 'domain',
+                    ip      = '192.0.2.5',
+                ),
+        ]
+        
+        self.options.unknown_host = 'ufc'
+        self.options.hosts_domain = 'domain'
+        self.assertZoneEquals(zone.apply_hosts_reverse(self.options, hosts, ipaddr.IPNetwork('192.0.2.1/29')), {
+            ('1', 'PTR'): ['foo.domain.'],
+            ('2', 'PTR'): ['ufc.domain.'],
+            ('3', 'PTR'): ['ufc.domain.'],
+            ('4', 'PTR'): ['ufc.domain.'],
+            ('5', 'PTR'): ['bar.domain.'],
+            ('6', 'PTR'): ['ufc.domain.'],
+        })
 
 if __name__ == '__main__':
     unittest.main()