test_dhcp.py
changeset 4 8b633782f02d
parent 3 ff98fa9b84ce
--- a/test_dhcp.py	Thu Apr 02 21:11:01 2009 +0300
+++ b/test_dhcp.py	Thu Apr 02 22:52:26 2009 +0300
@@ -1,22 +1,14 @@
 #!/usr/bin/env python2.5
 """
-    Test conf_dhcp
+    Test dhcp_conf
 """
 
-import dhcp_conf as dhcpc, dhcp, addr
+import dhcp_conf as dhcpc
+import test_conf, dhcp, addr
 
 import unittest
 
-class _TestConfObj (unittest.TestCase) :
-    def assert_obj (self, obj, lines) :
-        """
-            Formats the given conf.Object and compares the output against the given lines
-        """
-        
-        for obj_line, line in zip(obj.fmt_lines(), lines) :
-            self.assertEqual(obj_line, line)
-
-class TestDHCPConf (_TestConfObj) :
+class TestDHCPConf (test_conf._TestConfBase) :
     def assert_stmt (self, stmt, line) :
         """
             Formats the given Statement, and compares the output against the given line.
@@ -120,7 +112,8 @@
     
 class TestDHCP (_TestConfObj) :
     def test_host (self) :
-        self.assert_obj(dhcp.Host("testhost", addr.MAC("12:34:56:78:90:ab"), addr.IP("1.2.3.4")), [
+        self.assert_obj(dhcp.Host("testhost", addr.MAC("12:34:56:78:90:ab"), addr.IP("1.2.3.4"), comment="foo"), [
+                "# foo",
                 "host testhost {",
                 "\thardware ethernet 12:34:56:78:90:ab;",
                 "\tfixed-address 1.2.3.4;",
@@ -128,7 +121,8 @@
             ])
 
     def test_subnet (self) :
-        self.assert_obj(dhcp.Subnet(addr.Network("1.2.3.0/24")), [
+        self.assert_obj(dhcp.Subnet(addr.Network("1.2.3.0/24"), comment="bar"), [
+                "# bar",
                 "subnet 1.2.3.0 netmask 255.255.255.0 {",
                 "\toption routers 1.2.3.1;",
                 "}"