--- a/pvl/hosts/tests.py Tue Feb 24 19:18:45 2015 +0200
+++ b/pvl/hosts/tests.py Tue Feb 24 19:24:06 2015 +0200
@@ -27,13 +27,7 @@
for attr, value in attrs.iteritems():
self.assertEquals(getattr(host, attr), value)
- def testApply(self):
- self.assertHostsEqual(config.apply(self.options, ['etc/hosts/test']), [
- ('foo@test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
- ('bar@test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
- ])
-
- def testApplyHostsError(self):
+ def testApplyHostsFileError(self):
with self.assertRaises(config.HostConfigError):
list(config.apply_hosts(self.options, ['nonexistant']))
@@ -52,12 +46,31 @@
self.assertHostsEqual(config.apply_hosts_file(self.options, conf_file), expected)
+ def testApply(self):
+ self.assertHostsEqual(config.apply(self.options, ['etc/hosts/test']), [
+ ('foo@test', dict(
+ ip = ipaddr.IPAddress('127.0.0.1'),
+ ethernet = {None: '00:11:22:33:44:55'},
+ )),
+ ('bar@test', dict(
+ ip = ipaddr.IPAddress('127.0.0.2'),
+ ethernet = {None: '01:23:45:67:89:ab'},
+ )),
+ ])
+
def testApplyHostsExpand(self):
self.assertHostsEqual(config.apply_host_config(self.options, 'asdf', 'asdf{1-3}', ip='10.100.100.$'), [
('asdf1@asdf', dict(ip=ipaddr.IPAddress('10.100.100.1'))),
('asdf2@asdf', dict(ip=ipaddr.IPAddress('10.100.100.2'))),
('asdf3@asdf', dict(ip=ipaddr.IPAddress('10.100.100.3'))),
])
+
+ def testApplyHostsConfigError(self):
+ with self.assertRaises(config.HostConfigError):
+ config.apply_host(self.options, 'foo', 'test', {
+ 'ethernet': 'foo',
+ 'ethernet.eth0': 'bar',
+ })
if __name__ == '__main__':
unittest.main()