16 def setUp(self): |
16 def setUp(self): |
17 self.options = pvl.args.options( |
17 self.options = pvl.args.options( |
18 hosts_charset = 'utf-8', |
18 hosts_charset = 'utf-8', |
19 hosts_domain = None, |
19 hosts_domain = None, |
20 hosts_include = None, |
20 hosts_include = None, |
|
21 hosts_include_trace = None, |
21 ) |
22 ) |
22 |
23 |
23 def assertHostEqual(self, host, host_str, attrs): |
24 def assertHostEqual(self, host, host_str, attrs): |
24 self.assertEquals(str(host), host_str) |
25 self.assertEquals(str(host), host_str) |
25 |
26 |
183 ]) |
184 ]) |
184 |
185 |
185 |
186 |
186 def testApplyIncludePath(self): |
187 def testApplyIncludePath(self): |
187 self.options.hosts_include = 'etc/hosts' |
188 self.options.hosts_include = 'etc/hosts' |
188 self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/zones/forward/test']), [ |
189 include_trace = [ ] |
|
190 |
|
191 hosts = list(config.apply_hosts_files(self.options, ['etc/zones/forward/test'], |
|
192 include_trace = include_trace, |
|
193 )) |
|
194 |
|
195 self.assertHostsEqual(hosts, [ |
189 ('quux@asdf.test', dict( |
196 ('quux@asdf.test', dict( |
190 ip = ipaddr.IPAddress('192.0.2.5'), |
197 ip = ipaddr.IPAddress('192.0.2.5'), |
191 )), |
198 )), |
192 ('bar@test', dict( |
199 ('bar@test', dict( |
193 ip = ipaddr.IPAddress('192.0.2.2'), |
200 ip = ipaddr.IPAddress('192.0.2.2'), |
194 )), |
201 )), |
195 ('foo@test', dict( |
202 ('foo@test', dict( |
196 ip = ipaddr.IPAddress('192.0.2.1'), |
203 ip = ipaddr.IPAddress('192.0.2.1'), |
197 )), |
204 )), |
|
205 ]) |
|
206 |
|
207 self.assertEqual(include_trace, [ |
|
208 'etc/zones/forward/test', |
|
209 'etc/zones/forward/test/asdf.test', |
|
210 'etc/zones/forward/test/test', |
|
211 'etc/hosts/test.d/', |
|
212 'etc/hosts/test.d/bar', |
|
213 'etc/hosts/test.d/foo', |
198 ]) |
214 ]) |
199 |
215 |
200 def testApply(self): |
216 def testApply(self): |
201 self.assertHostsEqual(config.apply(self.options, ['etc/hosts/example.com']), [ |
217 self.assertHostsEqual(config.apply(self.options, ['etc/hosts/example.com']), [ |
202 ('foo@example.com', dict( |
218 ('foo@example.com', dict( |