author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Wed, 27 Mar 2013 15:03:14 +0100 | |
changeset 8791 | 892fc9e0c8df |
parent 8695 | 358d8bed9626 |
permissions | -rw-r--r-- |
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/>. |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
18 |
"""this module contains base classes for windmill integration |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
19 |
|
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
20 |
:todo: |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
21 |
|
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
22 |
* import CubicWeb session object into windmill scope to be able to run RQL |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
23 |
* manage command line option from pytest to run specific use tests only |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
24 |
""" |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
25 |
|
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
26 |
|
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
27 |
import os, os.path as osp |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
28 |
from logging import getLogger, ERROR |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
29 |
import sys |
5674
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 |
# imported by default to simplify further import statements |
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
32 |
from logilab.common.testlib import TestCase, unittest_main, Tags |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
33 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
34 |
try: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
35 |
import windmill |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
36 |
from windmill.dep import functest |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
37 |
from windmill.bin.admin_lib import configure_global_settings, setup, teardown |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8690
diff
changeset
|
38 |
except ImportError: |
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
39 |
windmill = None |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
40 |
|
6438
abae10f81a85
[js test] cleanup, move anonymous_logged handling to the test class (easier to control there
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6424
diff
changeset
|
41 |
from cubicweb.devtools.httptest import CubicWebServerTC, CubicWebServerConfig |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
42 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
43 |
if windmill is None: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
44 |
class CubicWebWindmillUseCase(CubicWebServerTC): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
45 |
tags = CubicWebServerTC.tags & Tags(('windmill',)) |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
46 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
47 |
def testWindmill(self): |
8690
c0a06ac390cc
[devtools] fix broken windmill test case
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7089
diff
changeset
|
48 |
self.skipTest("can't import windmill") |
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
49 |
else: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
50 |
# Excerpt from :ref:`windmill.authoring.unit` |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
51 |
class UnitTestReporter(functest.reports.FunctestReportInterface): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
52 |
def summary(self, test_list, totals_dict, stdout_capture): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
53 |
self.test_list = test_list |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
54 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
55 |
unittestreporter = UnitTestReporter() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
56 |
functest.reports.register_reporter(unittestreporter) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
57 |
|
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
58 |
class CubicWebWindmillUseCase(CubicWebServerTC): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
59 |
"""basic class for Windmill use case tests |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
60 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
61 |
If you want to change cubicweb test server parameters, define a new |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
62 |
:class:`CubicWebServerConfig` and override the :var:`configcls` |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
63 |
attribute: |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
64 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
65 |
configcls = CubicWebServerConfig |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
66 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
67 |
From Windmill configuration: |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
68 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
69 |
.. attribute:: browser |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
70 |
identification string (firefox|ie|safari|chrome) (firefox by default) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
71 |
.. attribute :: edit_test |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
72 |
load and edit test for debugging (False by default) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
73 |
.. attribute:: test_dir (optional) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
74 |
testing file path or directory (windmill directory under your unit case |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
75 |
file by default) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
76 |
|
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
77 |
Examples: |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
78 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
79 |
browser = 'firefox' |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
80 |
test_dir = osp.join(__file__, 'windmill') |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
81 |
edit_test = False |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
82 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
83 |
If you prefer, you can put here the use cases recorded by windmill GUI |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
84 |
(services transformer) instead of the windmill sub-directory |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
85 |
You can change `test_dir` as following: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
86 |
|
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
87 |
test_dir = __file__ |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
88 |
|
7061 | 89 |
Instead of toggle `edit_test` value, try `python <test script> -f` |
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
90 |
""" |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
91 |
browser = 'firefox' |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
92 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
93 |
edit_test = "-i" in sys.argv # detection for pytest invocation |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
94 |
# Windmill use case are written with no anonymous user |
7071
db7608cb32bc
[devtools] fix anonymous user handling in test classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7052
diff
changeset
|
95 |
anonymous_allowed = False |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
96 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
97 |
tags = CubicWebServerTC.tags & Tags(('windmill',)) |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
98 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
99 |
def _test_dir(self): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
100 |
"""access to class attribute if possible or make assumption |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
101 |
of expected directory""" |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
102 |
try: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
103 |
return getattr(self, 'test_dir') |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
104 |
except AttributeError: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
105 |
if os.path.basename(sys.argv[0]) == "pytest": |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
106 |
test_dir = os.getcwd() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
107 |
else: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
108 |
import inspect |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
109 |
test_dir = os.path.dirname(inspect.stack()[-1][1]) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
110 |
return osp.join(test_dir, 'windmill') |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
111 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
112 |
def setUp(self): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
113 |
# Start CubicWeb session before running the server to populate self.vreg |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
114 |
CubicWebServerTC.setUp(self) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
115 |
# XXX reduce log output (should be done in a cleaner way) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
116 |
# windmill fu** up our logging configuration |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
117 |
for logkey in ('windmill', 'logilab', 'cubicweb'): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
118 |
getLogger(logkey).setLevel(ERROR) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
119 |
self.test_dir = self._test_dir() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
120 |
msg = "provide a valid 'test_dir' as the given test file/dir (current: %s)" |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
121 |
assert os.path.exists(self.test_dir), (msg % self.test_dir) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
122 |
# windmill setup |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
123 |
windmill.stdout, windmill.stdin = sys.stdout, sys.stdin |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
124 |
configure_global_settings() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
125 |
windmill.settings['TEST_URL'] = self.config['base-url'] |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
126 |
if hasattr(self,"windmill_settings"): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
127 |
for (setting,value) in self.windmill_settings.iteritems(): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
128 |
windmill.settings[setting] = value |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
129 |
self.windmill_shell_objects = setup() |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
130 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
131 |
def tearDown(self): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
132 |
teardown(self.windmill_shell_objects) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
133 |
CubicWebServerTC.tearDown(self) |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
134 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
135 |
def testWindmill(self): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
136 |
if self.edit_test: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
137 |
# see windmill.bin.admin_options.Firebug |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
138 |
windmill.settings['INSTALL_FIREBUG'] = 'firebug' |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
139 |
windmill.settings.setdefault('MOZILLA_PLUGINS', []).extend( |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
140 |
['/usr/share/mozilla-extensions/', |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
141 |
'/usr/share/xul-ext/']) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
142 |
controller = self.windmill_shell_objects['start_' + self.browser]() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
143 |
self.windmill_shell_objects['do_test'](self.test_dir, |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
144 |
load=self.edit_test, |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
145 |
threaded=False) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
146 |
# set a breakpoint to be able to debug windmill test |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
147 |
if self.edit_test: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
148 |
import pdb; pdb.set_trace() |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
149 |
return |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
150 |
|
7052
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
151 |
# reporter |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
152 |
for test in unittestreporter.test_list: |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
153 |
msg = "" |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
154 |
self._testMethodDoc = getattr(test, "__doc__", None) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
155 |
self._testMethodName = test.__name__ |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
156 |
# try to display a better message in case of failure |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
157 |
if hasattr(test, "tb"): |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
158 |
msg = '\n'.join(test.tb) |
9680cf108821
[test/windmill] Gracefully skip windmill test if windmill can't be imported.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6438
diff
changeset
|
159 |
self.assertEqual(test.result, True, msg=msg) |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
160 |