devtools/cwwindmill.py
author katia
Mon, 21 Jun 2010 16:13:41 +0200
changeset 5819 1017163825c7
parent 5674 9378d13e9ac4
child 5995 b9c612274af7
permissions -rw-r--r--
[css] more css rework, need visual test in compat/new modes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5674
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     3
#
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     5
#
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     9
# any later version.
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    10
#
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    14
# details.
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    15
#
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    18
"""this module contains base classes for windmill integration"""
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    19
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    20
import os, os.path as osp
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    21
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    22
# imported by default to simplify further import statements
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    23
from logilab.common.testlib import unittest_main
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    24
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    25
from windmill.authoring import unit
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    26
from windmill.dep import functest
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    27
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    28
from cubicweb.devtools.httptest import CubicWebServerTC
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    29
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    30
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    31
class UnitTestReporter(functest.reports.FunctestReportInterface):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    32
    def summary(self, test_list, totals_dict, stdout_capture):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    33
        self.test_list = test_list
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    34
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    35
unittestreporter = UnitTestReporter()
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    36
functest.reports.register_reporter(unittestreporter)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    37
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    38
class CubicWebWindmillUseCase(CubicWebServerTC, unit.WindmillUnitTestCase):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    39
    """basic class for Windmill use case tests
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    40
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    41
    :param browser: browser identification string (firefox|ie|safari|chrome) (firefox by default)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    42
    :param test_dir: testing file path or directory (./windmill by default)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    43
    """
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    44
    browser = 'firefox'
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    45
    test_dir = osp.join(os.getcwd(), 'windmill')
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    46
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    47
    def setUp(self):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    48
        # reduce log output
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    49
        from logging import getLogger, ERROR
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    50
        getLogger('cubicweb').setLevel(ERROR)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    51
        getLogger('logilab').setLevel(ERROR)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    52
        getLogger('windmill').setLevel(ERROR)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    53
        # Start CubicWeb session before running the server to populate self.vreg
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    54
        CubicWebServerTC.setUp(self)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    55
        assert os.path.exists(self.test_dir), "provide 'test_dir' as the given test file/dir"
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    56
        unit.WindmillUnitTestCase.setUp(self)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    57
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    58
    def tearDown(self):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    59
        unit.WindmillUnitTestCase.tearDown(self)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    60
        CubicWebServerTC.tearDown(self)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    61
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    62
    def testWindmill(self):
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    63
        self.windmill_shell_objects['start_' + self.browser]()
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    64
        self.windmill_shell_objects['do_test'](self.test_dir, threaded=False)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    65
        for test in unittestreporter.test_list:
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    66
            self._testMethodDoc = getattr(test, "__doc__", None)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    67
            self._testMethodName = test.__name__
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    68
            self.assertEquals(test.result, True)
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    69
9378d13e9ac4 [web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    70