testSlapOSERP5SkinSelection.py 12.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
#                    Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################
import unittest
from Products.SlapOS.tests.testSlapOSMixin import \
  testSlapOSMixin

import difflib

class TestSlaposSkinSelection(testSlapOSMixin):
  run_all_test = 1

  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()],
        [
          'Download',
          'Hosting',
          'KM',
          'Multiflex',
Romain Courteaud's avatar
Romain Courteaud committed
63 64 65
          'ODS',
          'ODT',
          'RSS',
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
          'SHACACHE',
          'SHADIR',
          '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 = \
                            installed_selection_string_list.split(',')
    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_05_Hosting_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'Hosting'
    selection_string_list = \
"""
custom
vifib_hosting
114
slapos_accounting
115
slapos_administration
116 117 118 119
slapos_cache
slapos_cloud
slapos_cloud_promise
slapos_core
Romain Courteaud's avatar
Romain Courteaud committed
120
slapos_payzen
121 122
slapos_pdm
slapos_rest_api
123
slapos_simulation
124
slapos_slap_tool
Łukasz Nowak's avatar
Łukasz Nowak committed
125
slapos_web
126 127 128 129 130 131 132 133 134 135 136
vifib_hosting_theme
vifib_jauks_theme
vifib_jauks_widget_library
vifib_web
slapos_configurator
erp5_km
erp5_km_theme
erp5_knowledge_pad
erp5_simulation
erp5_dms_base
erp5_dms_web
Romain Courteaud's avatar
Romain Courteaud committed
137
erp5_accounting_l10n_fr
138 139 140 141
erp5_access_tab
erp5_accounting
erp5_accounting_bbb
erp5_base
Romain Courteaud's avatar
Romain Courteaud committed
142
erp5_bearer_token
143 144 145 146 147 148 149 150 151
erp5_commerce
erp5_commerce_widget_library
erp5_computer_immobilisation
erp5_configurator
erp5_configurator_wizard
erp5_content_translation
erp5_core
erp5_core_proxy_field_legacy
erp5_credential
Romain Courteaud's avatar
Romain Courteaud committed
152
erp5_credential_oauth2
153 154 155 156 157 158 159 160 161 162 163
erp5_crm
erp5_data_set
erp5_dhtml_style
erp5_dms
erp5_fckeditor
erp5_forge
erp5_forge_release
erp5_gadget
erp5_glossary
erp5_ingestion
erp5_ingestion_test
Łukasz Nowak's avatar
Łukasz Nowak committed
164
erp5_integration
165
erp5_invoicing
166 167 168
erp5_item
erp5_item_trade
erp5_jquery
Romain Courteaud's avatar
Romain Courteaud committed
169 170 171
erp5_ods_core
erp5_odt_core
erp5_ooo_import
172
erp5_open_trade
Romain Courteaud's avatar
Romain Courteaud committed
173
erp5_payzen_secure_payment
174
erp5_pdm
Romain Courteaud's avatar
Romain Courteaud committed
175 176
erp5_project
erp5_project_trade
177
erp5_promise
Romain Courteaud's avatar
Romain Courteaud committed
178
erp5_rss_core
Romain Courteaud's avatar
Romain Courteaud committed
179
erp5_secure_payment
180
erp5_simplified_invoicing
181
erp5_software_pdm
Romain Courteaud's avatar
Romain Courteaud committed
182
erp5_system_event
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
erp5_toolbox
erp5_trade
erp5_vcs
erp5_web
erp5_web_crm
erp5_web_minimal_theme
erp5_web_widget_library
erp5_workflow
erp5_xhtml_jquery_style
erp5_xhtml_style
external_method
Images
activity
zpt_content
zpt_control
zpt_generic
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

  def test_08_View_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'View'
    selection_string_list = \
"""
custom
212
slapos_accounting
213
slapos_administration
214 215 216 217
slapos_cache
slapos_cloud
slapos_cloud_promise
slapos_core
Romain Courteaud's avatar
Romain Courteaud committed
218
slapos_payzen
219 220
slapos_pdm
slapos_rest_api
221
slapos_simulation
222
slapos_slap_tool
Łukasz Nowak's avatar
Łukasz Nowak committed
223
slapos_web
224 225 226 227 228 229
slapos_configurator
erp5_km
erp5_knowledge_pad
erp5_simulation
erp5_dms_base
erp5_dms_web
Romain Courteaud's avatar
Romain Courteaud committed
230
erp5_accounting_l10n_fr
231 232 233 234
erp5_access_tab
erp5_accounting
erp5_accounting_bbb
erp5_base
Romain Courteaud's avatar
Romain Courteaud committed
235
erp5_bearer_token
236 237 238 239 240 241 242 243 244
erp5_commerce
erp5_commerce_widget_library
erp5_computer_immobilisation
erp5_configurator
erp5_configurator_wizard
erp5_content_translation
erp5_core
erp5_core_proxy_field_legacy
erp5_credential
Romain Courteaud's avatar
Romain Courteaud committed
245
erp5_credential_oauth2
246 247 248 249 250 251 252 253 254 255 256 257
erp5_crm
erp5_data_set
erp5_dhtml_style
erp5_dms
erp5_fckeditor
erp5_forge
erp5_forge_release
erp5_gadget
erp5_glossary
erp5_html_compatibility
erp5_ingestion
erp5_ingestion_test
Łukasz Nowak's avatar
Łukasz Nowak committed
258
erp5_integration
259
erp5_invoicing
260 261 262
erp5_item
erp5_item_trade
erp5_jquery
Romain Courteaud's avatar
Romain Courteaud committed
263 264 265
erp5_ods_core
erp5_odt_core
erp5_ooo_import
266
erp5_open_trade
Romain Courteaud's avatar
Romain Courteaud committed
267
erp5_payzen_secure_payment
268
erp5_pdm
Romain Courteaud's avatar
Romain Courteaud committed
269 270
erp5_project
erp5_project_trade
271
erp5_promise
Romain Courteaud's avatar
Romain Courteaud committed
272
erp5_rss_core
Romain Courteaud's avatar
Romain Courteaud committed
273
erp5_secure_payment
274
erp5_simplified_invoicing
275
erp5_software_pdm
Romain Courteaud's avatar
Romain Courteaud committed
276
erp5_system_event
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
erp5_toolbox
erp5_trade
erp5_vcs
erp5_web
erp5_web_crm
erp5_web_minimal_theme
erp5_web_widget_library
erp5_workflow
erp5_xhtml_jquery_style
erp5_xhtml_style
external_method
Images
activity
zpt_content
zpt_control
zpt_generic
"""
    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'
    selection_string_list = \
"""
custom
306
slapos_accounting
307
slapos_administration
308 309 310 311
slapos_cache
slapos_cloud
slapos_cloud_promise
slapos_core
Romain Courteaud's avatar
Romain Courteaud committed
312
slapos_payzen
313 314
slapos_pdm
slapos_rest_api
315
slapos_simulation
316
slapos_slap_tool
Łukasz Nowak's avatar
Łukasz Nowak committed
317
slapos_web
318 319 320 321 322 323 324
slapos_configurator
erp5_km
erp5_km_theme
erp5_knowledge_pad
erp5_simulation
erp5_dms_base
erp5_dms_web
Romain Courteaud's avatar
Romain Courteaud committed
325
erp5_accounting_l10n_fr
326 327 328 329
erp5_access_tab
erp5_accounting
erp5_accounting_bbb
erp5_base
Romain Courteaud's avatar
Romain Courteaud committed
330
erp5_bearer_token
331 332 333 334 335 336 337 338 339
erp5_commerce
erp5_commerce_widget_library
erp5_computer_immobilisation
erp5_configurator
erp5_configurator_wizard
erp5_content_translation
erp5_core
erp5_core_proxy_field_legacy
erp5_credential
Romain Courteaud's avatar
Romain Courteaud committed
340
erp5_credential_oauth2
341 342 343 344 345 346 347 348 349 350 351
erp5_crm
erp5_data_set
erp5_dhtml_style
erp5_dms
erp5_fckeditor
erp5_forge
erp5_forge_release
erp5_gadget
erp5_glossary
erp5_ingestion
erp5_ingestion_test
Łukasz Nowak's avatar
Łukasz Nowak committed
352
erp5_integration
353
erp5_invoicing
354 355 356
erp5_item
erp5_item_trade
erp5_jquery
Romain Courteaud's avatar
Romain Courteaud committed
357 358 359
erp5_ods_core
erp5_odt_core
erp5_ooo_import
360
erp5_km_widget_library
361
erp5_open_trade
Romain Courteaud's avatar
Romain Courteaud committed
362
erp5_payzen_secure_payment
363
erp5_pdm
Romain Courteaud's avatar
Romain Courteaud committed
364 365
erp5_project
erp5_project_trade
366
erp5_promise
Romain Courteaud's avatar
Romain Courteaud committed
367
erp5_rss_core
Romain Courteaud's avatar
Romain Courteaud committed
368
erp5_secure_payment
369
erp5_simplified_invoicing
370
erp5_software_pdm
Romain Courteaud's avatar
Romain Courteaud committed
371
erp5_system_event
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
erp5_toolbox
erp5_trade
erp5_vcs
erp5_web
erp5_web_crm
erp5_web_minimal_theme
erp5_web_widget_library
erp5_workflow
erp5_xhtml_jquery_style
erp5_xhtml_style
external_method
Images
activity
zpt_content
zpt_control
zpt_generic
"""
    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'
    selection_string_list = \
"""
custom
401
slapos_accounting
402
slapos_administration
403 404 405 406
slapos_cache
slapos_cloud
slapos_cloud_promise
slapos_core
Romain Courteaud's avatar
Romain Courteaud committed
407
slapos_payzen
408 409
slapos_pdm
slapos_rest_api
410
slapos_simulation
411
slapos_slap_tool
Łukasz Nowak's avatar
Łukasz Nowak committed
412
slapos_web
413 414 415 416 417 418 419
slapos_configurator
erp5_commerce_multiflex_layout
erp5_km
erp5_knowledge_pad
erp5_simulation
erp5_dms_base
erp5_dms_web
Romain Courteaud's avatar
Romain Courteaud committed
420
erp5_accounting_l10n_fr
421 422 423 424
erp5_access_tab
erp5_accounting
erp5_accounting_bbb
erp5_base
Romain Courteaud's avatar
Romain Courteaud committed
425
erp5_bearer_token
426 427 428 429 430 431 432 433 434
erp5_commerce
erp5_commerce_widget_library
erp5_computer_immobilisation
erp5_configurator
erp5_configurator_wizard
erp5_content_translation
erp5_core
erp5_core_proxy_field_legacy
erp5_credential
Romain Courteaud's avatar
Romain Courteaud committed
435
erp5_credential_oauth2
436 437 438 439 440 441 442 443 444 445 446
erp5_crm
erp5_data_set
erp5_dhtml_style
erp5_dms
erp5_fckeditor
erp5_forge
erp5_forge_release
erp5_gadget
erp5_glossary
erp5_ingestion
erp5_ingestion_test
Łukasz Nowak's avatar
Łukasz Nowak committed
447
erp5_integration
448
erp5_invoicing
449 450
erp5_item
erp5_item_trade
451
erp5_open_trade
Romain Courteaud's avatar
Romain Courteaud committed
452
erp5_payzen_secure_payment
453
erp5_pdm
Romain Courteaud's avatar
Romain Courteaud committed
454 455
erp5_project
erp5_project_trade
456
erp5_promise
Romain Courteaud's avatar
Romain Courteaud committed
457
erp5_rss_core
Romain Courteaud's avatar
Romain Courteaud committed
458
erp5_secure_payment
459
erp5_simplified_invoicing
460
erp5_software_pdm
Romain Courteaud's avatar
Romain Courteaud committed
461
erp5_system_event
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
erp5_toolbox
erp5_trade
erp5_vcs
erp5_web
erp5_web_crm
erp5_web_minimal_theme
erp5_web_widget_library
erp5_workflow
erp5_xhtml_jquery_style
external_method
Images
activity
zpt_content
zpt_control
zpt_generic
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

  def test_12_Download_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'Download'
    selection_string_list = \
"""
custom
490
slapos_accounting
491
slapos_administration
492 493 494 495
slapos_cache
slapos_cloud
slapos_cloud_promise
slapos_core
Romain Courteaud's avatar
Romain Courteaud committed
496
slapos_payzen
497 498
slapos_pdm
slapos_rest_api
499
slapos_simulation
500
slapos_slap_tool
Łukasz Nowak's avatar
Łukasz Nowak committed
501
slapos_web
502 503 504 505 506 507 508
slapos_configurator
erp5_km
erp5_web_download_theme
erp5_knowledge_pad
erp5_simulation
erp5_dms_base
erp5_dms_web
Romain Courteaud's avatar
Romain Courteaud committed
509
erp5_accounting_l10n_fr
510 511 512 513
erp5_access_tab
erp5_accounting
erp5_accounting_bbb
erp5_base
Romain Courteaud's avatar
Romain Courteaud committed
514
erp5_bearer_token
515 516 517 518 519 520 521 522 523
erp5_commerce
erp5_commerce_widget_library
erp5_computer_immobilisation
erp5_configurator
erp5_configurator_wizard
erp5_content_translation
erp5_core
erp5_core_proxy_field_legacy
erp5_credential
Romain Courteaud's avatar
Romain Courteaud committed
524
erp5_credential_oauth2
525 526 527 528 529 530 531 532 533 534 535
erp5_crm
erp5_data_set
erp5_dhtml_style
erp5_dms
erp5_fckeditor
erp5_forge
erp5_forge_release
erp5_gadget
erp5_glossary
erp5_ingestion
erp5_ingestion_test
Łukasz Nowak's avatar
Łukasz Nowak committed
536
erp5_integration
537
erp5_invoicing
538 539
erp5_item
erp5_item_trade
540
erp5_open_trade
Romain Courteaud's avatar
Romain Courteaud committed
541
erp5_payzen_secure_payment
542
erp5_pdm
Romain Courteaud's avatar
Romain Courteaud committed
543 544
erp5_project
erp5_project_trade
545
erp5_promise
Romain Courteaud's avatar
Romain Courteaud committed
546
erp5_rss_core
Romain Courteaud's avatar
Romain Courteaud committed
547
erp5_secure_payment
548
erp5_simplified_invoicing
549
erp5_software_pdm
Romain Courteaud's avatar
Romain Courteaud committed
550
erp5_system_event
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
erp5_toolbox
erp5_trade
erp5_vcs
erp5_web
erp5_web_crm
erp5_web_minimal_theme
erp5_web_widget_library
erp5_workflow
erp5_xhtml_jquery_style
erp5_xhtml_style
external_method
Images
activity
zpt_content
zpt_control
zpt_generic
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
"""
    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'
    selection_string_list = \
"""
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

  def test_14_ODT_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'ODT'
    selection_string_list = \
"""
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

  def test_15_RSS_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'RSS'
    selection_string_list = \
"""
"""
    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'
    selection_string_list = \
"""
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

  def test_17_SHADIR_selection(self, quiet=0, run=run_all_test):
    """
    Check the skin folder order
    """
    if not run: return

    skin_name = 'SHADIR'
    selection_string_list = \
"""
627 628 629 630 631 632 633
"""
    self.assertSameSkinSelection(skin_name, selection_string_list)

def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestSlaposSkinSelection))
  return suite