Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
Signed-off-by: Gustavo Y. Ribeiro <gyr(a)linux.vnet.ibm.com>
---
plugins/kimchi/tests/test_config.py.in | 109 +++++++++++++++-----------------
plugins/kimchi/tests/utils.py | 4 +-
2 files changed, 54 insertions(+), 59 deletions(-)
diff --git a/plugins/kimchi/tests/test_config.py.in
b/plugins/kimchi/tests/test_config.py.in
index 337218e..930d6d3 100644
--- a/plugins/kimchi/tests/test_config.py.in
+++ b/plugins/kimchi/tests/test_config.py.in
@@ -18,9 +18,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
+from cherrypy.lib.reprconf import Parser
-from wok import config
-from wok.config import Paths, PluginPaths, KimchiConfig
+from wok.plugins.kimchi import config as kconfig
+from wok.config import Paths, PluginPaths
get_prefix = None
@@ -43,48 +44,48 @@ class ConfigTests(unittest.TestCase):
self.assertEquals(actual, expected)
def test_installed_paths(self):
- Paths.get_prefix = lambda self: '@pkgdatadir@'
+ Paths.get_prefix = lambda self: '@datadir@/wok'
paths = Paths()
- self.assertInstalledPath(paths.state_dir, '/var/lib/kimchi')
- self.assertInstalledPath(paths.log_dir, '/var/log/kimchi')
- self.assertInstalledPath(paths.conf_dir, '/etc/kimchi')
- self.assertInstalledPath(paths.src_dir, '@kimchidir@')
- self.assertInstalledPath(paths.plugins_dir, '@kimchidir@/plugins')
- self.assertInstalledPath(paths.ui_dir, '@pkgdatadir@/ui')
+ self.assertInstalledPath(paths.state_dir, '/var/lib/wok')
+ self.assertInstalledPath(paths.log_dir, '/var/log/wok')
+ self.assertInstalledPath(paths.conf_dir, '/etc/wok')
+ self.assertInstalledPath(paths.src_dir, '@wokdir@')
+ self.assertInstalledPath(paths.plugins_dir, '@wokdir@/plugins')
+ self.assertInstalledPath(paths.ui_dir, '@datadir@/wok/ui')
self.assertInstalledPath(paths.mo_dir, '@prefix@/share/locale')
def test_uninstalled_paths(self):
- Paths.get_prefix = lambda self: '/home/user/kimchi'
+ Paths.get_prefix = lambda self: '/home/user/wok'
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')
+ self.assertEquals(paths.state_dir, '/home/user/wok/data')
+ self.assertEquals(paths.log_dir, '/home/user/wok/log')
+ self.assertEquals(paths.conf_dir, '/home/user/wok/src')
+ self.assertEquals(paths.src_dir, '/home/user/wok/src/wok')
+ self.assertEquals(paths.plugins_dir, '/home/user/wok/plugins')
+ self.assertEquals(paths.ui_dir, '/home/user/wok/ui')
+ self.assertEquals(paths.mo_dir, '/home/user/wok/mo')
def test_installed_plugin_paths(self):
- PluginPaths.get_prefix = lambda self: '@pkgdatadir@'
- paths = PluginPaths('sample')
- self.assertInstalledPath(paths.conf_dir, '/etc/kimchi/plugins.d')
+ PluginPaths.get_prefix = lambda self: '@datadir@/wok'
+ paths = PluginPaths('kimchi')
+ self.assertInstalledPath(paths.conf_dir, '/etc/wok/plugins.d')
self.assertInstalledPath(paths.conf_file,
- '/etc/kimchi/plugins.d/sample.conf')
- self.assertInstalledPath(paths.src_dir, '@kimchidir@/plugins/sample')
+ '/etc/wok/plugins.d/kimchi.conf')
+ self.assertInstalledPath(paths.src_dir, '@wokdir@/plugins/kimchi')
self.assertInstalledPath(paths.ui_dir,
- '@pkgdatadir@/plugins/sample/ui')
+ '@datadir@/wok/plugins/kimchi/ui')
self.assertInstalledPath(paths.mo_dir,
- '@pkgdatadir@/plugins/sample/mo')
+ '@datadir@/wok/plugins/kimchi/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')
+ PluginPaths.get_prefix = lambda self: '/home/user/wok'
+ paths = PluginPaths('kimchi')
+ self.assertEquals(paths.conf_dir, '/home/user/wok/plugins/kimchi')
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')
+ paths.conf_file, '/home/user/wok/plugins/kimchi/kimchi.conf')
+ self.assertEquals(paths.src_dir, '/home/user/wok/plugins/kimchi')
+ self.assertEquals(paths.ui_dir, '/home/user/wok/plugins/kimchi/ui')
+ self.assertEquals(paths.mo_dir, '/home/user/wok/plugins/kimchi/mo')
def test_kimchi_config(self):
Paths.get_prefix = PluginPaths.get_prefix = get_prefix
@@ -98,99 +99,93 @@ class ConfigTests(unittest.TestCase):
'tools.nocache.on': True,
'tools.proxy.on': True,
'tools.sessions.on': True,
- 'tools.sessions.name': 'kimchi',
+ 'tools.sessions.name': 'wok',
'tools.sessions.secure': True,
'tools.sessions.httponly': True,
'tools.sessions.locking': 'explicit',
'tools.sessions.storage_type': 'ram',
'tools.sessions.timeout': SESSIONSTIMEOUT,
- 'tools.kimchiauth.on': False
+ 'tools.wokauth.on': False
},
'/novnc': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': paths.novnc_dir,
+ 'tools.staticdir.dir': PluginPaths('kimchi').novnc_dir,
'tools.nocache.on': True,
- 'tools.kimchiauth.on': True
+ 'tools.wokauth.on': True
},
'/spice_auto.html': {
'tools.staticfile.on': True,
- 'tools.staticfile.filename': paths.spice_file,
+ 'tools.staticfile.filename':
PluginPaths('kimchi').spice_file,
'tools.nocache.on': True,
- 'tools.kimchiauth.on': True
+ 'tools.wokauth.on': True
},
'/spice-html5': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': paths.spice_dir,
+ 'tools.staticdir.dir': PluginPaths('kimchi').spice_dir,
'tools.nocache.on': True
},
'/spice-html5/spice.css': {
'tools.staticfile.on': True,
- 'tools.staticfile.filename': paths.spice_css_file,
+ 'tools.staticfile.filename':
PluginPaths('kimchi').spice_css_file,
'tools.nocache.on': True,
},
'/kimchi-ui.html': {
- 'tools.kimchiauth.on': True
+ 'tools.wokauth.on': True
},
'/css': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': '%s/ui/css' % paths.prefix,
+ 'tools.staticdir.dir': '%s/ui/css' %
PluginPaths('kimchi').prefix,
'tools.expires.on': True,
'tools.expires.secs': CACHEEXPIRES,
'tools.nocache.on': False
},
'/js': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': '%s/ui/js' % paths.prefix,
+ 'tools.staticdir.dir': '%s/ui/js' %
PluginPaths('kimchi').prefix,
'tools.expires.on': True,
'tools.expires.secs': CACHEEXPIRES,
'tools.nocache.on': False
},
'/libs': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': '%s/ui/libs' % paths.prefix,
+ 'tools.staticdir.dir': '%s/ui/libs' %
PluginPaths('kimchi').prefix,
'tools.expires.on': True,
'tools.expires.secs': CACHEEXPIRES,
'tools.nocache.on': False,
},
'/images': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': '%s/ui/images' % paths.prefix,
+ 'tools.staticdir.dir': '%s/ui/images' %
PluginPaths('kimchi').prefix,
'tools.nocache.on': False
},
'/data/screenshots': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': config.get_screenshot_path(),
+ 'tools.staticdir.dir': kconfig.get_screenshot_path(),
'tools.nocache.on': False
},
'/data/debugreports': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': config.get_debugreports_path(),
+ 'tools.staticdir.dir': kconfig.get_debugreports_path(),
'tools.nocache.on': False,
- 'tools.kimchiauth.on': True,
+ 'tools.wokauth.on': True,
'tools.staticdir.content_types': {'xz':
'application/x-xz'}
},
- '/config/ui/tabs.xml': {
- 'tools.staticfile.on': True,
- 'tools.staticfile.filename': '%s/config/ui/tabs.xml' %
- paths.prefix,
- 'tools.nocache.on': True
- },
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename':
- '%s/images/logo.ico' % paths.ui_dir
+ '%s/images/logo.ico' % PluginPaths('kimchi').ui_dir
},
'/robots.txt': {
'tools.staticfile.on': True,
- 'tools.staticfile.filename': '%s/robots.txt' %
paths.ui_dir
+ 'tools.staticfile.filename': '%s/robots.txt' %
PluginPaths('kimchi').ui_dir
},
'/help': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': '%s/ui/pages/help' %
paths.prefix,
+ 'tools.staticdir.dir': '%s/ui/pages/help' %
PluginPaths('kimchi').prefix,
'tools.staticdir.index': 'en_US/index.html',
'tools.nocache.on': True
}
}
- kimchi_config = KimchiConfig()
+ kimchi_config = Parser().dict_from_file(PluginPaths('kimchi').conf_file)
self.assertEquals(kimchi_config, configObj)
diff --git a/plugins/kimchi/tests/utils.py b/plugins/kimchi/tests/utils.py
index e22bffa..e224062 100644
--- a/plugins/kimchi/tests/utils.py
+++ b/plugins/kimchi/tests/utils.py
@@ -38,7 +38,7 @@ from lxml import etree
from wok.plugins.kimchi import mockmodel
import wok.server
-from wok.config import config, paths
+from wok.config import config, paths, PluginPaths
from wok.auth import User, USER_NAME, USER_GROUPS, USER_ROLES, tabs
from wok.exception import NotFoundError, OperationFailed
from wok.utils import wok_log
@@ -167,7 +167,7 @@ def get_remote_iso_path():
"""
host_arch = os.uname()[4]
remote_path = ''
- with open(os.path.join(paths.conf_dir, 'distros.d', 'fedora.json'))
\
+ with open(os.path.join(PluginPaths('kimchi').conf_dir, 'distros.d',
'fedora.json')) \
as fedora_isos:
# Get a list of dicts
json_isos_list = json.load(fedora_isos)
--
1.7.1