pvl.hosts.config: fix and test extensions
authorTero Marttila <tero.marttila@aalto.fi>
Thu, 26 Feb 2015 16:36:46 +0200
changeset 501 41b362e6074b
parent 500 60f2be893641
child 502 ac4e0f2df80c
pvl.hosts.config: fix and test extensions
pvl/hosts/host.py
pvl/hosts/tests.py
--- a/pvl/hosts/host.py	Thu Feb 26 16:24:00 2015 +0200
+++ b/pvl/hosts/host.py	Thu Feb 26 16:36:46 2015 +0200
@@ -112,7 +112,7 @@
             forward=None, reverse=None,
             down=None,
             boot=None,
-            **extensions
+            extensions=None,
     ) :
         """
             Return a Host initialized from data attributes.
@@ -134,7 +134,7 @@
                 reverse     = parse_str(reverse),
                 down        = parse_bool(down),
                 boot        = boot,
-                extensions  = extensions
+                extensions  = extensions,
         )
 
     def __init__ (self, name, domain,
--- a/pvl/hosts/tests.py	Thu Feb 26 16:24:00 2015 +0200
+++ b/pvl/hosts/tests.py	Thu Feb 26 16:36:46 2015 +0200
@@ -85,6 +85,22 @@
                 'ethernet.eth0': 'bar',
             })
 
+    def testApplyHostConfigExtensions(self):
+        host = config.apply_host(self.options, 'foo', 'test', {
+            'link:50':          'foo@test',
+            'link:uplink.49':   'bar@test',
+        })
+
+        self.assertHostEqual(host, 'foo@test', dict(
+                extensions = {
+                    'link': {
+                        '50': 'foo@test',
+                        'uplink': { '49': 'bar@test' },
+                    },
+                },
+        ))
+
+
 class TestZoneMixin(object):
     def assertZoneEquals(self, rrs, expected):
         gather = { }