[Kimchi-devel] [wok] Fix bug #724: Fix test_kimchi_config

Lucio Correia luciojhc at linux.vnet.ibm.com
Thu Sep 3 13:46:44 UTC 2015


This patch fixes Kimchi config test and adds Wok config
test.

IMPORTANT: this patch is based on Wok V3, but will conflict with Samuel's 
[PATCH 1/5] [WOK] Removing fontello references and unused CSS and old JS. The
fontello occurrences in test_config.py.in should be replaced with fontawesome.

Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 plugins/kimchi/config.py.in                |    6 +-
 plugins/kimchi/kimchi.conf                 |    8 --
 plugins/kimchi/tests/test_config.py.in     |  146 ++++++++++++++++++++++------
 plugins/kimchi/ui/images/Makefile.am       |    2 +-
 plugins/kimchi/ui/images/logo.ico          |  Bin 1214 -> 0 bytes
 plugins/kimchi/ui/pages/help/dita-help.xsl |    2 +-
 src/wok/config.py.in                       |    8 ++
 7 files changed, 131 insertions(+), 41 deletions(-)
 delete mode 100644 plugins/kimchi/ui/images/logo.ico

diff --git a/plugins/kimchi/config.py.in b/plugins/kimchi/config.py.in
index 80b72bd..2974e7e 100644
--- a/plugins/kimchi/config.py.in
+++ b/plugins/kimchi/config.py.in
@@ -23,7 +23,7 @@ import os
 import platform
 import threading
 
-from wok.config import PluginPaths
+from wok.config import PluginConfig, PluginPaths
 from wok.xmlutils.utils import xpath_get_text
 
 kimchiLock = threading.Lock()
@@ -103,9 +103,9 @@ class KimchiPaths(PluginPaths):
 kimchiPaths = KimchiPaths()
 
 
-class KimchiConfig(dict):
+class KimchiConfig(PluginConfig):
     def __init__(self):
-        super(KimchiConfig, self).__init__(self)
+        super(KimchiConfig, self).__init__('kimchi')
 
         custom_config = {
             '/novnc': {
diff --git a/plugins/kimchi/kimchi.conf b/plugins/kimchi/kimchi.conf
index 78f4f3f..1bf78e4 100644
--- a/plugins/kimchi/kimchi.conf
+++ b/plugins/kimchi/kimchi.conf
@@ -30,14 +30,6 @@ tools.nocache.on = False
 tools.wokauth.on = True
 tools.staticdir.content_types = {'xz': 'application/x-xz'}
 
-[/favicon.ico]
-tools.staticfile.on = True
-tools.staticfile.filename = wok.config.PluginPaths('kimchi').ui_dir + '/images/logo.ico'
-
-[/robots.txt]
-tools.staticfile.on = True
-tools.staticfile.filename = wok.config.PluginPaths('kimchi').ui_dir + '/robots.txt'
-
 [/help]
 tools.staticdir.on = True
 tools.staticdir.dir = wok.config.PluginPaths('kimchi').ui_dir + '/pages/help'
diff --git a/plugins/kimchi/tests/test_config.py.in b/plugins/kimchi/tests/test_config.py.in
index 6bca3df..7bd28bc 100644
--- a/plugins/kimchi/tests/test_config.py.in
+++ b/plugins/kimchi/tests/test_config.py.in
@@ -20,11 +20,11 @@
 import unittest
 from cherrypy.lib.reprconf import Parser
 
-from wok.config import Paths
+from wok.config import Paths, PluginPaths, WokConfig
 
 from wok.plugins.kimchi.config import get_debugreports_path
 from wok.plugins.kimchi.config import get_screenshot_path
-from wok.plugins.kimchi.config import KimchiPaths
+from wok.plugins.kimchi.config import KimchiConfig, KimchiPaths
 
 from wok.plugins.kimchi import config as kconfig
 
@@ -92,8 +92,9 @@ class ConfigTests(unittest.TestCase):
         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 = KimchiPaths.get_prefix = get_prefix
+    def test_wok_config(self):
+        Paths.get_prefix = PluginPaths.get_prefix = get_prefix
+        paths = Paths()
         CACHEEXPIRES = 31536000
         SESSIONSTIMEOUT = 10
         configObj = {
@@ -111,56 +112,154 @@ class ConfigTests(unittest.TestCase):
                 'tools.sessions.timeout': SESSIONSTIMEOUT,
                 'tools.wokauth.on': False
             },
+            '/wok-ui.html': {
+                'tools.wokauth.on': True
+            },
+            '/css': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/css' % paths.prefix,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/fontello': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/fontello' % paths.prefix,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/js': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/js' % paths.prefix,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/libs': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/libs' % paths.prefix,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/images': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/images' % paths.prefix,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/favicon.ico': {
+                'tools.staticfile.on': True,
+                'tools.staticfile.filename':
+                '%s/images/logo.ico' % paths.ui_dir
+            },
+            '/robots.txt': {
+                'tools.staticfile.on': True,
+                'tools.staticfile.filename': '%s/robots.txt' % paths.ui_dir
+            },
+        }
+
+        wok_config = WokConfig()
+        self.assertEquals(wok_config, configObj)
+
+
+    def test_kimchi_config(self):
+        KimchiPaths.get_prefix = PluginPaths.get_prefix = get_prefix
+        paths = KimchiPaths()
+        pluginPrefix = paths.add_prefix(paths.plugin_dir)
+        CACHEEXPIRES = 31536000
+        SESSIONSTIMEOUT = 10
+        configObj = {
+            'wok': {
+                'enable': True,
+                'plugin_class': "KimchiRoot",
+                'uri': '/%s' % paths.plugin_dir,
+                'extra_auth_api_class': "control.sub_nodes"
+            },
+            '/': {
+                'tools.trailing_slash.on': False,
+                'request.methods_with_bodies': ('POST', 'PUT'),
+                'tools.nocache.on': True,
+                'tools.proxy.on': True,
+                'tools.sessions.on': True,
+                '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.wokauth.on': True
+            },
             '/novnc': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': KimchiPaths().novnc_dir,
+                'tools.staticdir.dir': paths.novnc_dir,
                 'tools.nocache.on': True,
                 'tools.wokauth.on': True
             },
             '/spice_auto.html': {
                 'tools.staticfile.on': True,
-                'tools.staticfile.filename': KimchiPaths().spice_file,
+                'tools.staticfile.filename': paths.spice_file,
                 'tools.nocache.on': True,
                 'tools.wokauth.on': True
             },
             '/spice-html5': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': KimchiPaths().spice_dir,
+                'tools.staticdir.dir': paths.spice_dir,
                 'tools.nocache.on': True
             },
             '/spice-html5/spice.css': {
                 'tools.staticfile.on': True,
-                'tools.staticfile.filename': KimchiPaths().spice_css_file,
+                'tools.staticfile.filename': paths.spice_css_file,
                 'tools.nocache.on': True,
             },
-            '/kimchi-ui.html': {
-                'tools.wokauth.on': True
+            '/ui/config/tab-ext.xml': {
+                'tools.staticfile.on': True,
+                'tools.staticfile.filename': '%s/ui/config/tab-ext.xml' %
+                pluginPrefix,
+                'tools.nocache.on': True
             },
             '/css': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': '%s/ui/css' % KimchiPaths().prefix,
+                'tools.staticdir.dir': '%s/ui/css' % pluginPrefix,
                 'tools.expires.on': True,
                 'tools.expires.secs': CACHEEXPIRES,
-                'tools.nocache.on': False
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
+            },
+            '/fontello': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': '%s/ui/fontello' % pluginPrefix,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
             },
             '/js': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': '%s/ui/js' % KimchiPaths().prefix,
+                'tools.staticdir.dir': '%s/ui/js' % pluginPrefix,
                 'tools.expires.on': True,
                 'tools.expires.secs': CACHEEXPIRES,
-                'tools.nocache.on': False
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
             },
             '/libs': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': '%s/ui/libs' % KimchiPaths().prefix,
+                'tools.staticdir.dir': '%s/ui/libs' % pluginPrefix,
                 'tools.expires.on': True,
                 'tools.expires.secs': CACHEEXPIRES,
                 'tools.nocache.on': False,
+                'tools.wokauth.on': False,
             },
             '/images': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': '%s/ui/images' % KimchiPaths().prefix,
-                'tools.nocache.on': False
+                'tools.staticdir.dir': '%s/ui/images' % pluginPrefix,
+                'tools.nocache.on': False,
+                'tools.wokauth.on': False
             },
             '/data/screenshots': {
                 'tools.staticdir.on': True,
@@ -174,22 +273,13 @@ class ConfigTests(unittest.TestCase):
                 'tools.wokauth.on': True,
                 'tools.staticdir.content_types': {'xz': 'application/x-xz'}
             },
-            '/favicon.ico': {
-                'tools.staticfile.on': True,
-                'tools.staticfile.filename':
-                '%s/images/logo.ico' % KimchiPaths().ui_dir
-            },
-            '/robots.txt': {
-                'tools.staticfile.on': True,
-                'tools.staticfile.filename': '%s/robots.txt' % KimchiPaths().ui_dir
-            },
             '/help': {
                 'tools.staticdir.on': True,
-                'tools.staticdir.dir': '%s/ui/pages/help' % KimchiPaths().prefix,
-                'tools.staticdir.index': 'en_US/index.html',
+                'tools.staticdir.dir': '%s/ui/pages/help' % pluginPrefix,
                 'tools.nocache.on': True
             }
         }
 
         kimchi_config = Parser().dict_from_file(KimchiPaths().conf_file)
+        kimchi_config.update(KimchiConfig())
         self.assertEquals(kimchi_config, configObj)
diff --git a/plugins/kimchi/ui/images/Makefile.am b/plugins/kimchi/ui/images/Makefile.am
index 0562e6a..ca3ee6e 100644
--- a/plugins/kimchi/ui/images/Makefile.am
+++ b/plugins/kimchi/ui/images/Makefile.am
@@ -19,4 +19,4 @@ SUBDIRS = theme-default
 
 imagedir = $(datadir)/wok/plugins/kimchi/ui/images
 
-dist_image_DATA = *.png *.ico
+dist_image_DATA = *.png
diff --git a/plugins/kimchi/ui/images/logo.ico b/plugins/kimchi/ui/images/logo.ico
deleted file mode 100644
index 446143f066a60f479b2cb8f8d04ab3c97ff60e56..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1214
zcma)*3rLeu6vyu=X_;nPV)$&PPF)r(wTQ|dTGOUtnOdf0mZ=cR#99xbub1{BqnD9^
z^Z>PV6h)fUny6#CN{3di2P{*h2ek at Oq0a4o*=I}2Iv?krbAR`oKi_vQA0faVCr83o
zF{!X2#Dx$Nz}$(sm^sgR<Jj30yCMGpMl1z837jm3H1$<DU4IV>Tbdw<FM-;Hi<#et
z=I}n~iB^qh8{XzCNyvT<I;$&znmT~?eFXZgAE at Om?1h(6Iq+2e1-ca!zOAO7n3*};
zXq6n?2kF<!f%cez;-Fgx4$e+xo{WR;oqhc_OW;#nF!Zm|JK}m8gi6aC+##`QA5PmJ
zfeZ(o(}%&&1P5#*1vVbnssk~XhN5bNz=T)>5^+BS=V54SJ|^z)5I7%kU;>-skiq*{
z5B^=eF<T)pK9+)bV;9UCK>t-HOi+bkR-wK1xpfXL;S<?ho1pQ5gYzxiHR~=e+XHS(
zYe7QMZb3IjWV72H-JpD~6z(tbgwn1o$D2s!YteWNJS!i9l%iW?+34Lvr*KL(6{_X|
zobEjAb{lD|4qsmYvGF;~r0Aunc#>=c)0W4s|D{#(q9~vaX{rGms=((Wn*~LeWqIu}
zkGvlzwaxjL25hey2bVweu<xK*t+ at Oa_)UKTK^x4IwmKMOjm at oL`l)}_NGPy}tdb}w
zHa>H`ji2N7m}Xsj#j7-`#=Dv}`)h&)9th^&^dR%>WH_MB8KcIXVf8p&s1xD|_k)R-
zrk$Z0-|Gf}&4Au$KhU$k?3YR5by~D9M&-q$=ocNz4!IY&p7%OxuJf&+Ei-G(23hU;
zHTLhMtjFR9ExVbPQVLzBFlROcIZ|#jmX6fm_hsVa3XP<aKAeAt8dqp&oBW=V^+d>Q
zkcNnm%Ds?ggd^Rv2~9_o82cv;p6LSBD_g_s-n1uZ8#<EeLwTm~LE9J!Zdo at M&*jFU
zoM+Z%F5)(8$8y`Wz~%Pd;Nlx at aH{<lk}}CcRMRXZMD&%Uhz3Ze$jpg#uec1IlFMPW
MDQ4iZEk#_;cNAJoqyPW_

diff --git a/plugins/kimchi/ui/pages/help/dita-help.xsl b/plugins/kimchi/ui/pages/help/dita-help.xsl
index 8583a4e..45f0a3b 100644
--- a/plugins/kimchi/ui/pages/help/dita-help.xsl
+++ b/plugins/kimchi/ui/pages/help/dita-help.xsl
@@ -9,7 +9,7 @@
             <head>
                 <title><xsl:value-of select="/cshelp/title" /></title>
                 <meta charset="UTF-8" />
-                <link rel="shortcut icon" href="../../images/logo.ico" />
+                <link rel="shortcut icon" href="images/logo.ico" />
                 <link rel="stylesheet" type="text/css" href="../kimchi.css" />
             </head>
             <body>
diff --git a/src/wok/config.py.in b/src/wok/config.py.in
index 5ffa936..bebe12b 100644
--- a/src/wok/config.py.in
+++ b/src/wok/config.py.in
@@ -142,6 +142,14 @@ class WokConfig(dict):
         '/wok-ui.html': {
             'tools.wokauth.on': True
         },
+        '/favicon.ico': {
+            'tools.staticfile.on': True,
+            'tools.staticfile.filename': '%s/images/logo.ico' % paths.ui_dir
+        },
+        '/robots.txt': {
+            'tools.staticfile.on': True,
+            'tools.staticfile.filename': '%s/robots.txt' % paths.ui_dir
+        },
     }
 
     def __init__(self):
-- 
1.7.1




More information about the Kimchi-devel mailing list