author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 30 Nov 2010 15:05:07 +0100 | |
changeset 6712 | 3e6cd6048be8 |
parent 6438 | abae10f81a85 |
child 7052 | 9680cf108821 |
child 7059 | 1d65b235549f |
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 |
6341
ad5e08981153
[tests] import TestSuite from lgc.testlib for further compatibility
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6322
diff
changeset
|
32 |
from logilab.common.testlib import TestCase, unittest_main |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
33 |
|
6322
711e7e8c69e3
[windmill] initialize windmill registry if not already existing (possible error case in dev)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6036
diff
changeset
|
34 |
import windmill |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
35 |
from windmill.dep import functest |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
36 |
from windmill.bin.admin_lib import configure_global_settings, setup, teardown |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
37 |
|
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
|
38 |
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
|
39 |
|
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
40 |
|
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
41 |
# Excerpt from :ref:`windmill.authoring.unit` |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
42 |
class UnitTestReporter(functest.reports.FunctestReportInterface): |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
43 |
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
|
44 |
self.test_list = test_list |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
45 |
|
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
46 |
unittestreporter = UnitTestReporter() |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
47 |
functest.reports.register_reporter(unittestreporter) |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
48 |
|
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
49 |
class CubicWebWindmillUseCase(CubicWebServerTC): |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
50 |
"""basic class for Windmill use case tests |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
51 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
52 |
If you want to change cubicweb test server parameters, define a new |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
53 |
:class:`CubicWebServerConfig` and override the :var:`configcls` |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
54 |
attribute: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
55 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
56 |
configcls = CubicWebServerConfig |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
57 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
58 |
From Windmill configuration: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
59 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
60 |
.. attribute:: browser |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
61 |
identification string (firefox|ie|safari|chrome) (firefox by default) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
62 |
.. attribute :: edit_test |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
63 |
load and edit test for debugging (False by default) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
64 |
.. attribute:: test_dir (optional) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
65 |
testing file path or directory (windmill directory under your unit case |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
66 |
file by default) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
67 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
68 |
Examples: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
69 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
70 |
browser = 'firefox' |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
71 |
test_dir = osp.join(__file__, 'windmill') |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
72 |
edit_test = False |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
73 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
74 |
If you prefer, you can put here the use cases recorded by windmill GUI |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
75 |
(services transformer) instead of the windmill sub-directory |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
76 |
You can change `test_dir` as following: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
77 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
78 |
test_dir = __file__ |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
79 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
80 |
Instead of toggle `edit_test` value, try `pytest -i` |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
81 |
""" |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
82 |
browser = 'firefox' |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
83 |
edit_test = "-i" in sys.argv # detection for pytest invocation |
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
|
84 |
# Windmill use case are written with no anonymous user |
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
|
85 |
anonymous_logged = False |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
86 |
|
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
87 |
def _test_dir(self): |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
88 |
"""access to class attribute if possible or make assumption |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
89 |
of expected directory""" |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
90 |
try: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
91 |
return getattr(self, 'test_dir') |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
92 |
except AttributeError: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
93 |
if os.path.basename(sys.argv[0]) == "pytest": |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
94 |
test_dir = os.getcwd() |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
95 |
else: |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
96 |
import inspect |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
97 |
test_dir = os.path.dirname(inspect.stack()[-1][1]) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
98 |
return osp.join(test_dir, 'windmill') |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
99 |
|
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
100 |
def setUp(self): |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
101 |
# Start CubicWeb session before running the server to populate self.vreg |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
102 |
CubicWebServerTC.setUp(self) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
103 |
# XXX reduce log output (should be done in a cleaner way) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
104 |
# windmill fu** up our logging configuration |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
105 |
for logkey in ('windmill', 'logilab', 'cubicweb'): |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
106 |
getLogger(logkey).setLevel(ERROR) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
107 |
self.test_dir = self._test_dir() |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
108 |
msg = "provide a valid 'test_dir' as the given test file/dir (current: %s)" |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
109 |
assert os.path.exists(self.test_dir), (msg % self.test_dir) |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
110 |
# windmill setup |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
111 |
windmill.stdout, windmill.stdin = sys.stdout, sys.stdin |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
112 |
configure_global_settings() |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
113 |
windmill.settings['TEST_URL'] = self.config['base-url'] |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
114 |
if hasattr(self,"windmill_settings"): |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
115 |
for (setting,value) in self.windmill_settings.iteritems(): |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
116 |
windmill.settings[setting] = value |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
117 |
self.windmill_shell_objects = setup() |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
118 |
|
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
119 |
def tearDown(self): |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
120 |
teardown(self.windmill_shell_objects) |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
121 |
CubicWebServerTC.tearDown(self) |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
122 |
|
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
123 |
def testWindmill(self): |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
124 |
if self.edit_test: |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
125 |
# see windmill.bin.admin_options.Firebug |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
126 |
windmill.settings['INSTALL_FIREBUG'] = 'firebug' |
6322
711e7e8c69e3
[windmill] initialize windmill registry if not already existing (possible error case in dev)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6036
diff
changeset
|
127 |
windmill.settings.setdefault('MOZILLA_PLUGINS', []).extend( |
6424
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
128 |
['/usr/share/mozilla-extensions/', |
f443a2b8a5c7
[devtools] refactor http server initialization in a much saner way
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6369
diff
changeset
|
129 |
'/usr/share/xul-ext/']) |
6322
711e7e8c69e3
[windmill] initialize windmill registry if not already existing (possible error case in dev)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6036
diff
changeset
|
130 |
controller = self.windmill_shell_objects['start_' + self.browser]() |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
131 |
self.windmill_shell_objects['do_test'](self.test_dir, |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
132 |
load=self.edit_test, |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
133 |
threaded=False) |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
134 |
# set a breakpoint to be able to debug windmill test |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
135 |
if self.edit_test: |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
136 |
import pdb; pdb.set_trace() |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
137 |
return |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
138 |
|
6322
711e7e8c69e3
[windmill] initialize windmill registry if not already existing (possible error case in dev)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6036
diff
changeset
|
139 |
# reporter |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
140 |
for test in unittestreporter.test_list: |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
141 |
msg = "" |
5674
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
142 |
self._testMethodDoc = getattr(test, "__doc__", None) |
9378d13e9ac4
[web test] Add windmill functional testing capability.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff
changeset
|
143 |
self._testMethodName = test.__name__ |
5995
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
144 |
# try to display a better message in case of failure |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
145 |
if hasattr(test, "tb"): |
b9c612274af7
[test] improve windmill integration, new test on relation edition
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5674
diff
changeset
|
146 |
msg = '\n'.join(test.tb) |
6369
a151453dc564
[test] more update to unittest2 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6341
diff
changeset
|
147 |
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
|
148 |