NACK, need improve commit message
we should configure with system path. or test case will failed.
On 01/27/2014 04:00 PM, Mark Wu wrote:
This patch adds test cases for paths generation code.
Signed-off-by: Mark Wu <wudxw(a)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(a)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')
+
My distros is F20
$ sudo ./run_tests.sh test_config
FF..
======================================================================
FAIL: test_installed_paths (test_config.ConfigTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_config.py", line 33, in test_installed_paths
self.assertEquals(paths.state_dir, '/var/lib/kimchi')
AssertionError: '/usr/share/kimchi/data' != '/var/lib/kimchi'
======================================================================
FAIL: test_installed_plugin_paths (test_config.ConfigTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_config.py", line 57, in test_installed_plugin_paths
self.assertEquals(paths.conf_dir, '/etc/kimchi/plugins.d')
AssertionError: '/usr/share/kimchi/plugins/sample' !=
'/etc/kimchi/plugins.d'
----------------------------------------------------------------------
Ran 4 tests in 0.001s
FAILED (failures=2)
+ 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')
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center