--- a/pvl/hosts/tests.py Thu Feb 26 17:24:13 2015 +0200
+++ b/pvl/hosts/tests.py Thu Feb 26 17:27:36 2015 +0200
@@ -31,53 +31,6 @@
self.assertHostEqual(host, host_str, attrs)
- def testApplyHostsFileError(self):
- with self.assertRaises(config.HostConfigError):
- list(config.apply_hosts_files(self.options, ['nonexistant']))
-
- def testApplyHosts(self):
- conf_file = ConfFile('test', """
-[foo]
- ip = 127.0.0.1
-
-[bar]
- ip = 127.0.0.2
- """)
- expected = [
- ('foo@test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
- ('bar@test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
- ]
-
- 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 testApplyHostFqdn(self):
- self.assertHostsEqual(config.apply_hosts('test', 'asdf@foo.test', { }), [
- ('asdf@foo.test', dict()),
- ])
-
- self.assertHostsEqual(config.apply_hosts('test', 'asdf.test2', { }), [
- ('asdf.test2@', dict()),
- ])
-
- def testApplyHostExpand(self):
- self.assertHostsEqual(config.apply_hosts('test', 'asdf{1-3}', { 'ip': '10.100.100.$' }), [
- ('asdf1@test', dict(ip=ipaddr.IPAddress('10.100.100.1'))),
- ('asdf2@test', dict(ip=ipaddr.IPAddress('10.100.100.2'))),
- ('asdf3@test', dict(ip=ipaddr.IPAddress('10.100.100.3'))),
- ])
-
def testApplyHostConfigDict(self):
host = config.apply_host('foo', 'test', {
'ethernet.eth0': '00:11:22:33:44:55',
@@ -121,7 +74,53 @@
},
},
))
+
+ def testApplyHostFqdn(self):
+ self.assertHostsEqual(config.apply_hosts('test', 'asdf@foo.test', { }), [
+ ('asdf@foo.test', dict()),
+ ])
+ self.assertHostsEqual(config.apply_hosts('test', 'asdf.test2', { }), [
+ ('asdf.test2@', dict()),
+ ])
+
+ def testApplyHostExpand(self):
+ self.assertHostsEqual(config.apply_hosts('test', 'asdf{1-3}', { 'ip': '10.100.100.$' }), [
+ ('asdf1@test', dict(ip=ipaddr.IPAddress('10.100.100.1'))),
+ ('asdf2@test', dict(ip=ipaddr.IPAddress('10.100.100.2'))),
+ ('asdf3@test', dict(ip=ipaddr.IPAddress('10.100.100.3'))),
+ ])
+
+ def testApplyHostsFileError(self):
+ with self.assertRaises(config.HostConfigError):
+ list(config.apply_hosts_files(self.options, ['nonexistant']))
+
+ def testApplyHosts(self):
+ conf_file = ConfFile('test', """
+[foo]
+ ip = 127.0.0.1
+
+[bar]
+ ip = 127.0.0.2
+ """)
+ expected = [
+ ('foo@test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
+ ('bar@test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
+ ]
+
+ 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'},
+ )),
+ ])
class TestZoneMixin(object):
def assertZoneEquals(self, rrs, expected):