author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 07 Oct 2011 11:47:09 +0200 | |
branch | stable |
changeset 7916 | 54e240c1b419 |
parent 6632 | 78878f5a8166 |
child 9639 | 74b3db5bb41d |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
import sys |
19 |
import os |
|
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
20 |
from os.path import join |
0 | 21 |
from cStringIO import StringIO |
22 |
from logilab.common.testlib import TestCase, unittest_main |
|
23 |
||
24 |
from cubicweb.cwconfig import CubicWebConfiguration |
|
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
25 |
from cubicweb.devtools.testlib import CubicWebTC |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
26 |
from cubicweb.server.migractions import ServerMigrationHelper |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
27 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
28 |
CubicWebConfiguration.load_cwctl_plugins() # XXX necessary? |
0 | 29 |
|
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
30 |
|
0 | 31 |
class CubicWebCtlTC(TestCase): |
32 |
def setUp(self): |
|
33 |
self.stream = StringIO() |
|
34 |
sys.stdout = self.stream |
|
35 |
def tearDown(self): |
|
36 |
sys.stdout = sys.__stdout__ |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
37 |
|
0 | 38 |
def test_list(self): |
39 |
from cubicweb.cwctl import ListCommand |
|
6197
d8f0dce0b86d
[test] fixes to follow recent changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5436
diff
changeset
|
40 |
ListCommand(None).run([]) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
41 |
|
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
42 |
|
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
43 |
class CubicWebShellTC(CubicWebTC): |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
44 |
|
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
45 |
def test_process_script_args_context(self): |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
46 |
repo = self.cnx._repo |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
47 |
mih = ServerMigrationHelper(None, repo=repo, cnx=self.cnx, |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
48 |
interactive=False, |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
49 |
# hack so it don't try to load fs schema |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
50 |
schema=1) |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
51 |
scripts = {'script1.py': list(), |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
52 |
'script2.py': ['-v'], |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
53 |
'script3.py': ['-vd', '-f', 'FILE.TXT'], |
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
54 |
} |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
55 |
mih.cmd_process_script(join(self.datadir, 'scripts', 'script1.py'), |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
56 |
funcname=None) |
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
57 |
for script, args in scripts.items(): |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
58 |
scriptname = os.path.join(self.datadir, 'scripts', script) |
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
59 |
self.assert_(os.path.exists(scriptname)) |
5436
2455ca3a2a3a
[c-c shell] make script arguments available as __args__ in the script namespace. Use scriptargs instead of args as process_script argument name.
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5430
diff
changeset
|
60 |
mih.cmd_process_script(scriptname, None, scriptargs=args) |
5430
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
61 |
|
ed8f71e244f8
[shell] #715938: support of script parameters (using standard '--' as arguments separator)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
5426
diff
changeset
|
62 |
|
0 | 63 |
if __name__ == '__main__': |
64 |
unittest_main() |