author | David Douard <david.douard@logilab.fr> |
Tue, 19 Jul 2016 19:30:10 +0200 | |
branch | 3.22 |
changeset 11438 | 828483a88825 |
parent 10965 | b1ba18016151 |
permissions | -rw-r--r-- |
10965
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
1 |
# copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
3 |
# |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
4 |
# This file is part of CubicWeb. |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
5 |
# |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
9 |
# any later version. |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
10 |
# |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
14 |
# details. |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
15 |
# |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
18 |
"""unit tests for cubicweb-ctl commands from devtools""" |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
19 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
20 |
import os.path as osp |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
21 |
import sys |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
22 |
import tempfile |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
23 |
import shutil |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
24 |
from subprocess import Popen, PIPE, STDOUT |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
25 |
from unittest import TestCase |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
26 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
27 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
28 |
class CubicWebCtlTC(TestCase): |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
29 |
"""test case for devtools commands""" |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
30 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
31 |
def test_newcube(self): |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
32 |
cwctl = osp.abspath(osp.join(osp.dirname(__file__), '../../bin/cubicweb-ctl')) |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
33 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
34 |
tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube") |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
35 |
try: |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
36 |
cmd = [sys.executable, cwctl, 'newcube', |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
37 |
'--directory', tmpdir, 'foo'] |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
38 |
proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
39 |
stdout, _ = proc.communicate(b'short_desc\n') |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
40 |
finally: |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
41 |
shutil.rmtree(tmpdir, ignore_errors=True) |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
42 |
self.assertEqual(proc.returncode, 0, msg=stdout) |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
43 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
44 |
|
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
45 |
if __name__ == '__main__': |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
46 |
from unittest import main |
b1ba18016151
[skeleton] Fix broken spec file template
Rémi Cardona <remi.cardona@logilab.fr>
parents:
diff
changeset
|
47 |
main() |