pvl/hosts/tests.py
changeset 511 99043eab9140
parent 510 368a568412ed
child 513 3b45b4fd5102
--- a/pvl/hosts/tests.py	Thu Feb 26 18:07:03 2015 +0200
+++ b/pvl/hosts/tests.py	Thu Feb 26 18:19:09 2015 +0200
@@ -99,7 +99,7 @@
         with self.assertRaises(config.HostConfigError):
             list(config.apply_hosts_files(self.options, ['nonexistant']))
 
-    def testApplyHostsFile(self):
+    def testApplyHostsConfig(self):
         conf_file = ConfFile('test', """
 [foo]
     ip = 127.0.0.1
@@ -107,12 +107,27 @@
 [bar]
     ip = 127.0.0.2
         """)
-        expected = [
+        
+        self.assertHostsEqual(config.apply_hosts_config(self.options, conf_file), [
                 ('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_config(self.options, conf_file), expected)
+    def testApplyHostsConfigNested(self):
+        conf_file = ConfFile('test', """
+[asdf]
+    [[foo]]
+        ip = 127.0.0.1
+
+[quux]
+    [[bar]]
+        ip = 127.0.0.2
+        """)
+
+        self.assertHostsEqual(config.apply_hosts_config(self.options, conf_file), [
+                ('foo@asdf.test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
+                ('bar@quux.test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
+        ])
 
     def testApplyIncludes(self):
         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/includes.test']), [
@@ -129,6 +144,9 @@
 
     def testApplyDirectory(self):
         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/included.test/']), [
+                ('quux@asdf.included.test', dict(
+                    ip          = ipaddr.IPAddress('192.0.2.5'),
+                )),
                 ('foo@included.test', dict(
                     ip          = ipaddr.IPAddress('192.0.2.1'),
                 )),