--- a/pvl/hosts/tests.py Thu Feb 26 15:05:04 2015 +0200
+++ b/pvl/hosts/tests.py Thu Feb 26 15:05:18 2015 +0200
@@ -495,5 +495,69 @@
], None)
])
+ def testHosts(self):
+ hosts = [
+ Host.build('foo', 'test',
+ ip = '192.0.2.1',
+ ethernet = '00:11:22:33:44:55',
+ ),
+ Host.build('bar', 'test',
+ ip = '192.0.2.2',
+ ethernet = '01:23:45:67:89:ab',
+ ),
+ ]
+
+ self.assertBlocksEqual(list(dhcp.dhcp_hosts(hosts)), [
+ (('host', 'foo'), [
+ ('option', 'host-name', "foo"),
+ ('fixed-address', '192.0.2.1'),
+ ('hardware', 'ethernet', '00:11:22:33:44:55'),
+ ], None),
+ (('host', 'bar'), [
+ ('option', 'host-name', "bar"),
+ ('fixed-address', '192.0.2.2'),
+ ('hardware', 'ethernet', '01:23:45:67:89:ab'),
+ ], None),
+ ])
+
+ def testHostConflict(self):
+ hosts = [
+ Host.build('foo', 'test1',
+ ethernet = '00:11:22:33:44:55',
+ ),
+ Host.build('foo', 'test2',
+ ethernet = '01:23:45:67:89:ab',
+ ),
+ ]
+
+ with self.assertRaises(dhcp.HostDHCPError):
+ list(dhcp.dhcp_hosts(hosts))
+
+ def testHostMultinet(self):
+ hosts = [
+ Host.build('foo', 'test1',
+ ip = '192.0.1.1',
+ ethernet = { 'eth1': '00:11:22:33:44:55' },
+ ),
+ Host.build('foo', 'test2',
+ ip = '192.0.2.1',
+ ethernet = { 'eth2': '01:23:45:67:89:ab' },
+ ),
+ ]
+
+ self.assertBlocksEqual(list(dhcp.dhcp_hosts(hosts)), [
+ (('host', 'foo-eth1'), [
+ ('option', 'host-name', "foo"),
+ ('fixed-address', '192.0.1.1'),
+ ('hardware', 'ethernet', '00:11:22:33:44:55'),
+ ], None),
+ (('host', 'foo-eth2'), [
+ ('option', 'host-name', "foo"),
+ ('fixed-address', '192.0.2.1'),
+ ('hardware', 'ethernet', '01:23:45:67:89:ab'),
+ ], None),
+ ])
+
+
if __name__ == '__main__':
unittest.main()