Commit a29761e3 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Clean up Skin Selection tests

   This makes easy to overwrite and custom the list on sub-level projects
parent 7918f6c7
...@@ -19,43 +19,18 @@ ...@@ -19,43 +19,18 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import unittest
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import difflib import difflib
class TestSlaposSkinSelection(SlapOSTestCaseMixin):
run_all_test = 1
class TestSlaposSkinSelectionMixin(SlapOSTestCaseMixin):
# Ignore these bt5 as they might be present on development instances # Ignore these bt5 as they might be present on development instances
# but not present on the test. # but not present on the test.
ignore_list = [ ignore_list = [
# UI testing folders not deployed by Configurator # UI testing folders not deployed by Configurator
"slapos_ui_test", "slapos_ui_test"]
# Legacy and/or custom bt5 folders expected_available_skin = [
"slapos_vifib", "rapid_space", "rapid_space_ui_test"]
def getTitle(self):
return "Slapos Skin Selection"
def test_01_defaultSkin(self, quiet=0, run=run_all_test):
"""
Check default skin
"""
if not run: return
self.assertSameSet(
self.portal.portal_skins.getDefaultSkin(),
'View')
def test_01_availableSkin(self, quiet=0, run=run_all_test):
"""
Check that available skins are the same than production server
"""
if not run: return
portal = self.getPortal()
self.assertSameSet(
[x[0] for x in portal.portal_skins.getSkinPaths()],
[
'Deferred', 'Deferred',
'Deploy', 'Deploy',
'Download', 'Download',
...@@ -73,50 +48,8 @@ class TestSlaposSkinSelection(SlapOSTestCaseMixin): ...@@ -73,50 +48,8 @@ class TestSlaposSkinSelection(SlapOSTestCaseMixin):
'SlideShow', 'SlideShow',
'View' 'View'
] ]
)
def assertSameSkinSelection(self, skin_name, selection_string_list):
if selection_string_list.startswith('\n'):
selection_string_list = selection_string_list[1:]
if selection_string_list.endswith('\n'):
selection_string_list = selection_string_list[:-1]
installed_selection_string_list = \
self.portal.portal_skins.getSkinPath(skin_name)
selection_string_list = selection_string_list.split('\n') redirect_assistant_selection_string_list = \
installed_selection_string_list = \
[ i for i in installed_selection_string_list.split(',')
if i not in self.ignore_list]
if selection_string_list != installed_selection_string_list:
message = '\nSkin "%s" is different from production server:\n' % skin_name
for line in difflib.unified_diff(
selection_string_list,
installed_selection_string_list
):
message += '\t%s\n' % line
message += '\n'
message += 'Removed skin folder:\n'
for i in [x for x in selection_string_list if x not in
installed_selection_string_list]:
message += '\t - %s\n' % i
message += 'Added skin folder:\n'
for i in [x for x in installed_selection_string_list if x not in
selection_string_list]:
message += '\t + %s\n' % i
self.fail(message)
def test_092_RedirectAssist_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'RedirectAssist'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -227,18 +160,8 @@ external_method ...@@ -227,18 +160,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_091_Deffered_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'Deferred' deffered_selection_string_list = \
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -348,17 +271,8 @@ external_method ...@@ -348,17 +271,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_09_Deploy_selection(self, quiet=0, run=run_all_test): deploy_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'Deploy'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -469,16 +383,8 @@ external_method ...@@ -469,16 +383,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_08_View_selection(self, quiet=0, run=run_all_test): view_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'View'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -590,16 +496,8 @@ external_method ...@@ -590,16 +496,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_10_KM_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'KM' km_selection_string_list = \
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -712,16 +610,8 @@ external_method ...@@ -712,16 +610,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_11_Multiflex_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'Multiflex' multiflex_selection_string_list = \
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -831,16 +721,8 @@ external_method ...@@ -831,16 +721,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_12_Download_selection(self, quiet=0, run=run_all_test): download_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'Download'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -951,16 +833,8 @@ external_method ...@@ -951,16 +833,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_13_ODS_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'ODS' ods_selection_string_list = \
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1070,16 +944,8 @@ external_method ...@@ -1070,16 +944,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_14_ODT_selection(self, quiet=0, run=run_all_test): odt_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'ODT'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1189,16 +1055,8 @@ external_method ...@@ -1189,16 +1055,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_15_RSS_selection(self, quiet=0, run=run_all_test): rss_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'RSS'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1309,16 +1167,8 @@ external_method ...@@ -1309,16 +1167,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_16_SHACACHE_selection(self, quiet=0, run=run_all_test):
"""
Check the skin folder order
"""
if not run: return
skin_name = 'SHACACHE' shadir_selection_string_list = \
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1342,7 +1192,7 @@ slapos_simulation ...@@ -1342,7 +1192,7 @@ slapos_simulation
slapos_slap_tool slapos_slap_tool
slapos_wechat slapos_wechat
slapos_configurator slapos_configurator
erp5_web_shacache erp5_web_shadir
erp5_km erp5_km
erp5_web_download_theme erp5_web_download_theme
erp5_knowledge_pad erp5_knowledge_pad
...@@ -1430,16 +1280,8 @@ external_method ...@@ -1430,16 +1280,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_17_SHADIR_selection(self, quiet=0, run=run_all_test): shacache_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'SHADIR'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1463,7 +1305,7 @@ slapos_simulation ...@@ -1463,7 +1305,7 @@ slapos_simulation
slapos_slap_tool slapos_slap_tool
slapos_wechat slapos_wechat
slapos_configurator slapos_configurator
erp5_web_shadir erp5_web_shacache
erp5_km erp5_km
erp5_web_download_theme erp5_web_download_theme
erp5_knowledge_pad erp5_knowledge_pad
...@@ -1551,16 +1393,8 @@ external_method ...@@ -1551,16 +1393,8 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def test_18_RJS_selection(self, quiet=0, run=run_all_test): rjs_selection_string_list = \
"""
Check the skin folder order
"""
if not run: return
skin_name = 'RJS'
selection_string_list = \
""" """
custom custom
erp5_font erp5_font
...@@ -1671,10 +1505,129 @@ external_method ...@@ -1671,10 +1505,129 @@ external_method
slapos_disaster_recovery slapos_disaster_recovery
Images Images
""" """
self.assertSameSkinSelection(skin_name, selection_string_list)
def getTitle(self):
return "Slapos Skin Selection"
def test_01_defaultSkin(self):
"""
Check default skin
"""
self.assertSameSet(
self.portal.portal_skins.getDefaultSkin(),
'View')
def assertSameSkinSelection(self, skin_name, selection_string_list):
if selection_string_list.startswith('\n'):
selection_string_list = selection_string_list[1:]
if selection_string_list.endswith('\n'):
selection_string_list = selection_string_list[:-1]
installed_selection_string_list = \
self.portal.portal_skins.getSkinPath(skin_name)
selection_string_list = selection_string_list.split('\n')
installed_selection_string_list = \
[ i for i in installed_selection_string_list.split(',')
if i not in self.ignore_list]
if selection_string_list != installed_selection_string_list:
message = '\nSkin "%s" is different from production server:\n' % skin_name
for line in difflib.unified_diff(
selection_string_list,
installed_selection_string_list
):
message += '\t%s\n' % line
message += '\n'
message += 'Removed skin folder:\n'
for i in [x for x in selection_string_list if x not in
installed_selection_string_list]:
message += '\t - %s\n' % i
message += 'Added skin folder:\n'
for i in [x for x in installed_selection_string_list if x not in
selection_string_list]:
message += '\t + %s\n' % i
self.fail(message)
def _test_01_availableSkin(self):
"""
Check that available skins are the same than production server
"""
portal = self.getPortal()
self.assertSameSet(
[x[0] for x in portal.portal_skins.getSkinPaths()],
self.expected_available_skin
)
def _test_092_RedirectAssist_selection(self):
self.assertSameSkinSelection('RedirectAssist',
self.redirect_assistant_selection_string_list)
def _test_091_Deffered_selection(self):
self.assertSameSkinSelection('Deferred',
self.deffered_selection_string_list)
def _test_09_Deploy_selection(self):
self.assertSameSkinSelection("Deploy",
self.deploy_selection_string_list)
def _test_08_View_selection(self):
self.assertSameSkinSelection('View',
self.view_selection_string_list)
def _test_10_KM_selection(self):
self.assertSameSkinSelection("KM",
self.km_selection_string_list)
def _test_11_Multiflex_selection(self):
self.assertSameSkinSelection("Multiflex",
self.multiflex_selection_string_list)
def _test_12_Download_selection(self):
self.assertSameSkinSelection("Download",
self.download_selection_string_list)
def _test_13_ODS_selection(self):
self.assertSameSkinSelection("ODS",
self.ods_selection_string_list)
def _test_14_ODT_selection(self):
self.assertSameSkinSelection("ODT",
self.odt_selection_string_list)
def _test_15_RSS_selection(self):
self.assertSameSkinSelection("RSS",
self.rss_selection_string_list)
def _test_16_SHACACHE_selection(self):
self.assertSameSkinSelection("SHACACHE",
self.shacache_selection_string_list)
def _test_17_SHADIR_selection(self):
self.assertSameSkinSelection("SHADIR",
self.shadir_selection_string_list)
def _test_18_RJS_selection(self):
self.assertSameSkinSelection("RJS",
self.rjs_selection_string_list)
class TestSlaposSkinSelection(TestSlaposSkinSelectionMixin):
def test_suite(): test_01_availableSkin = TestSlaposSkinSelectionMixin._test_01_availableSkin
suite = unittest.TestSuite() test_092_RedirectAssist_selection = TestSlaposSkinSelectionMixin._test_092_RedirectAssist_selection
suite.addTest(unittest.makeSuite(TestSlaposSkinSelection)) test_091_Deffered_selection = TestSlaposSkinSelectionMixin._test_091_Deffered_selection
return suite test_09_Deploy_selection = TestSlaposSkinSelectionMixin._test_09_Deploy_selection
test_08_View_selection = TestSlaposSkinSelectionMixin._test_08_View_selection
test_10_KM_selection = TestSlaposSkinSelectionMixin._test_10_KM_selection
test_11_Multiflex_selection = TestSlaposSkinSelectionMixin._test_11_Multiflex_selection
test_12_Download_selection = TestSlaposSkinSelectionMixin._test_12_Download_selection
test_13_ODS_selection = TestSlaposSkinSelectionMixin._test_13_ODS_selection
test_14_ODT_selection = TestSlaposSkinSelectionMixin._test_14_ODT_selection
test_15_RSS_selection = TestSlaposSkinSelectionMixin._test_15_RSS_selection
test_16_SHACACHE_selection = TestSlaposSkinSelectionMixin._test_16_SHACACHE_selection
test_17_SHADIR_selection = TestSlaposSkinSelectionMixin._test_17_SHADIR_selection
test_18_RJS_selection = TestSlaposSkinSelectionMixin._test_18_RJS_selection
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment