cubicweb/devtools/test/unittest_devctl.py
changeset 11057 0b59724cb3f2
parent 10965 b1ba18016151
child 11099 5fdbf6f2db88
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
       
     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__),
       
    33                                      '../../../bin/cubicweb-ctl'))
       
    34 
       
    35         tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube")
       
    36         try:
       
    37             cmd = [sys.executable, cwctl, 'newcube',
       
    38                    '--directory', tmpdir, 'foo']
       
    39             proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
       
    40             stdout, _ = proc.communicate(b'short_desc\n')
       
    41         finally:
       
    42             shutil.rmtree(tmpdir, ignore_errors=True)
       
    43         self.assertEqual(proc.returncode, 0, msg=stdout)
       
    44 
       
    45 
       
    46 if __name__ == '__main__':
       
    47     from unittest import main
       
    48     main()