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