[Kimchi-devel] [PATCH v2 2/3] Add test cases for paths generation code

Mark Wu wudxw at linux.vnet.ibm.com
Fri Jan 24 06:31:42 UTC 2014


This patch adds test cases for paths generation code.

Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
 tests/test_config.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 tests/test_config.py

diff --git a/tests/test_config.py b/tests/test_config.py
new file mode 100644
index 0000000..4ad88f0
--- /dev/null
+++ b/tests/test_config.py
@@ -0,0 +1,73 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Mark Wu <wudxw at linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+import unittest
+
+
+from kimchi.config import Paths, PluginPaths
+
+
+class ConfigTests(unittest.TestCase):
+    def test_installed_paths(self):
+        Paths.get_prefix = lambda self: '/usr/share/kimchi'
+        paths = Paths()
+        self.assertEquals(paths.state_dir, '/var/lib/kimchi')
+        self.assertEquals(paths.log_dir, '/var/log/kimchi')
+        self.assertEquals(paths.conf_dir, '/etc/kimchi')
+        self.assertEquals(paths.src_dir,
+                          '/usr/lib/python2.7/site-packages/kimchi')
+        self.assertEquals(paths.plugins_dir,
+                          '/usr/lib/python2.7/site-packages/kimchi')
+        self.assertEquals(paths.ui_dir, '/usr/share/kimchi/ui')
+        self.assertEquals(paths.mo_dir, '/usr/share/kimchi/mo')
+
+    def test_uninstalled_paths(self):
+        Paths.get_prefix = lambda self: '/home/user/kimchi'
+        paths = Paths()
+        self.assertEquals(paths.state_dir, '/home/user/kimchi/data')
+        self.assertEquals(paths.log_dir, '/home/user/kimchi/log')
+        self.assertEquals(paths.conf_dir, '/home/user/kimchi/src')
+        self.assertEquals(paths.src_dir, '/home/user/kimchi/src/kimchi')
+        self.assertEquals(paths.plugins_dir, '/home/user/kimchi/plugins')
+        self.assertEquals(paths.ui_dir, '/home/user/kimchi/ui')
+        self.assertEquals(paths.mo_dir, '/home/user/kimchi/mo')
+
+    def test_installed_plugin_paths(self):
+        PluginPaths.get_prefix = lambda self: '/usr/share/kimchi'
+        paths = PluginPaths('sample')
+        self.assertEquals(paths.conf_dir, '/etc/kimchi/plugins.d')
+        self.assertEquals(paths.conf_file, '/etc/kimchi/plugins.d/sample.conf')
+        self.assertEquals(
+            paths.src_dir,
+            '/usr/lib/python2.7/site-packages/kimchi/plugins/sample')
+        self.assertEquals(paths.ui_dir, '/usr/share/kimchi/plugins/sample/ui')
+        self.assertEquals(paths.mo_dir, '/usr/share/kimchi/plugins/sample/mo')
+
+    def test_uninstalled_plugin_paths(self):
+        PluginPaths.get_prefix = lambda self: '/home/user/kimchi'
+        paths = PluginPaths('sample')
+        self.assertEquals(paths.conf_dir, '/home/user/kimchi/plugins/sample')
+        self.assertEquals(
+            paths.conf_file, '/home/user/kimchi/plugins/sample/sample.conf')
+        self.assertEquals(paths.src_dir, '/home/user/kimchi/plugins/sample')
+        self.assertEquals(paths.ui_dir, '/home/user/kimchi/plugins/sample/ui')
+        self.assertEquals(paths.mo_dir, '/home/user/kimchi/plugins/sample/mo')
-- 
1.8.4.2




More information about the Kimchi-devel mailing list