27 self.assertEquals(getattr(host, attr), value) |
27 self.assertEquals(getattr(host, attr), value) |
28 |
28 |
29 def assertHostsEqual(self, hosts, expected): |
29 def assertHostsEqual(self, hosts, expected): |
30 hosts = list(hosts) |
30 hosts = list(hosts) |
31 |
31 |
32 for host, expect in zip(hosts, expected): |
32 for host, expect in itertools.izip_longest(hosts, expected): |
|
33 self.assertIsNotNone(host, expect) |
|
34 self.assertIsNotNone(expect, host) |
|
35 |
33 host_str, attrs = expect |
36 host_str, attrs = expect |
34 |
37 |
35 self.assertHostEqual(host, host_str, attrs) |
38 self.assertHostEqual(host, host_str, attrs) |
36 |
39 |
37 self.assertEqual(len(hosts), len(expected)) |
|
38 |
|
39 def testApplyHostConfigDict(self): |
40 def testApplyHostConfigDict(self): |
40 host = config.apply_host('foo', 'test', { |
41 host = config.apply_host('foo', 'test', { |
41 'ethernet.eth0': '00:11:22:33:44:55', |
42 'ethernet.eth0': '00:11:22:33:44:55', |
42 }) |
43 }) |
43 |
44 |
164 )), |
165 )), |
165 ('foo@test', dict( |
166 ('foo@test', dict( |
166 ip = ipaddr.IPAddress('192.0.2.1'), |
167 ip = ipaddr.IPAddress('192.0.2.1'), |
167 )), |
168 )), |
168 ]) |
169 ]) |
|
170 |
|
171 def testApplyIncludesDefaults(self): |
|
172 self.assertHostsEqual(config.apply_hosts_config(self.options, ConfFile('test', """ |
|
173 boot.next-server = boot.lan |
|
174 |
|
175 include = etc/hosts/test |
|
176 """)), [ |
|
177 ('bar@test', dict( |
|
178 ip = ipaddr.IPAddress('192.0.2.2'), |
|
179 )), |
|
180 ('foo@test', dict( |
|
181 ip = ipaddr.IPAddress('192.0.2.1'), |
|
182 )), |
|
183 ]) |
|
184 |
169 |
185 |
170 def testApplyIncludePath(self): |
186 def testApplyIncludePath(self): |
171 self.options.hosts_include = 'etc/hosts' |
187 self.options.hosts_include = 'etc/hosts' |
172 self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/zones/forward/test']), [ |
188 self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/zones/forward/test']), [ |
173 ('quux@asdf.test', dict( |
189 ('quux@asdf.test', dict( |