pvl.hosts: test config.apply_host()
authorTero Marttila <tero.marttila@aalto.fi>
Wed, 25 Feb 2015 14:23:04 +0200
changeset 461 e3bddc5eeff5
parent 460 c93adfce8ae9
child 462 6d699c76d75d
pvl.hosts: test config.apply_host()
pvl/hosts/tests.py
--- a/pvl/hosts/tests.py	Wed Feb 25 14:22:49 2015 +0200
+++ b/pvl/hosts/tests.py	Wed Feb 25 14:23:04 2015 +0200
@@ -18,14 +18,17 @@
     def setUp(self):
         self.options = Options()
 
+    def assertHostEqual(self, host, host_str, attrs):
+        self.assertEquals(str(host), host_str)
+
+        for attr, value in attrs.iteritems():
+            self.assertEquals(getattr(host, attr), value)
+
     def assertHostsEqual(self, hosts, expected):
         for host, expect in zip(hosts, expected):
             host_str, attrs = expect
 
-            self.assertEquals(str(host), host_str)
-
-            for attr, value in attrs.iteritems():
-                self.assertEquals(getattr(host, attr), value)
+            self.assertHostEqual(host, host_str, attrs)
  
     def testApplyHostsFileError(self):
         with self.assertRaises(config.HostConfigError):
@@ -64,7 +67,16 @@
                 ('asdf2@asdf', dict(ip=ipaddr.IPAddress('10.100.100.2'))),
                 ('asdf3@asdf', dict(ip=ipaddr.IPAddress('10.100.100.3'))),
         ])
-    
+
+    def testApplyHostConfigDict(self):
+        host = config.apply_host(self.options, 'foo', 'test', {
+            'ethernet.eth0': '00:11:22:33:44:55',
+        })
+
+        self.assertHostEqual(host, 'foo@test', dict(
+                ethernet    = { 'eth0': '00:11:22:33:44:55' }
+        ))
+   
     def testApplyHostsConfigError(self):
         with self.assertRaises(config.HostConfigError):
             config.apply_host(self.options, 'foo', 'test', {