Browse Source

[trac615] Eliminate hardcoded values

They need to be put to the test file, if they are not default values of
parameters.
Michal 'vorner' Vaner 14 years ago
parent
commit
7a3dc628e9

+ 2 - 3
src/lib/python/isc/config/cfgmgr.py

@@ -44,7 +44,7 @@ class ConfigManagerData:
     """This class hold the actual configuration information, and
     """This class hold the actual configuration information, and
        reads it from and writes it to persistent storage"""
        reads it from and writes it to persistent storage"""
 
 
-    def __init__(self, data_path, file_name="b10-config.db"):
+    def __init__(self, data_path, file_name):
         """Initialize the data for the configuration manager, and
         """Initialize the data for the configuration manager, and
            set the version and path for the data store. Initializing
            set the version and path for the data store. Initializing
            this does not yet read the database, a call to
            this does not yet read the database, a call to
@@ -159,8 +159,7 @@ class ConfigManager:
        channel session. If not, a new session will be created.
        channel session. If not, a new session will be created.
        The ability to specify a custom session is for testing purposes
        The ability to specify a custom session is for testing purposes
        and should not be needed for normal usage."""
        and should not be needed for normal usage."""
-    def __init__(self, data_path, database_filename="b10-config.db",
+    def __init__(self, data_path, database_filename, session=None):
-                 session=None):
         """Initialize the configuration manager. The data_path string
         """Initialize the configuration manager. The data_path string
            is the path to the directory where the configuration is
            is the path to the directory where the configuration is
            stored (in <data_path>/<database_filename> or in
            stored (in <data_path>/<database_filename> or in

+ 5 - 3
src/lib/python/isc/config/tests/cfgmgr_test.py

@@ -27,7 +27,8 @@ class TestConfigManagerData(unittest.TestCase):
     def setUp(self):
     def setUp(self):
         self.data_path = os.environ['CONFIG_TESTDATA_PATH']
         self.data_path = os.environ['CONFIG_TESTDATA_PATH']
         self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
         self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
-        self.config_manager_data = ConfigManagerData(self.writable_data_path)
+        self.config_manager_data = ConfigManagerData(self.writable_data_path,
+                                                     file_name="b10-config.db")
         self.assert_(self.config_manager_data)
         self.assert_(self.config_manager_data)
 
 
     def test_abs_file(self):
     def test_abs_file(self):
@@ -78,8 +79,8 @@ class TestConfigManagerData(unittest.TestCase):
         # by equality of the .data element. If data_path or db_filename
         # by equality of the .data element. If data_path or db_filename
         # are different, but the contents are the same, it's still
         # are different, but the contents are the same, it's still
         # considered equal
         # considered equal
-        cfd1 = ConfigManagerData(self.data_path)
+        cfd1 = ConfigManagerData(self.data_path, file_name="b10-config.db")
-        cfd2 = ConfigManagerData(self.data_path)
+        cfd2 = ConfigManagerData(self.data_path, file_name="b10-config.db")
         self.assertEqual(cfd1, cfd2)
         self.assertEqual(cfd1, cfd2)
         cfd2.data_path = "some/unknown/path"
         cfd2.data_path = "some/unknown/path"
         self.assertEqual(cfd1, cfd2)
         self.assertEqual(cfd1, cfd2)
@@ -96,6 +97,7 @@ class TestConfigManager(unittest.TestCase):
         self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
         self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
         self.fake_session = FakeModuleCCSession()
         self.fake_session = FakeModuleCCSession()
         self.cm = ConfigManager(self.writable_data_path,
         self.cm = ConfigManager(self.writable_data_path,
+                                database_filename="b10-config.db",
                                 session=self.fake_session)
                                 session=self.fake_session)
         self.name = "TestModule"
         self.name = "TestModule"
         self.spec = isc.config.module_spec_from_file(self.data_path + os.sep + "/spec2.spec")
         self.spec = isc.config.module_spec_from_file(self.data_path + os.sep + "/spec2.spec")