cubicweb/test/unittest_cwctl.py
branch3.25
changeset 12120 707139a9eb00
parent 12053 c3c9f2e1424c
child 12121 86ec847835cd
equal deleted inserted replaced
12119:c4ed3f6463f6 12120:707139a9eb00
    21 from io import StringIO, BytesIO
    21 from io import StringIO, BytesIO
    22 import unittest
    22 import unittest
    23 
    23 
    24 from six import PY2
    24 from six import PY2
    25 
    25 
       
    26 from mock import patch
       
    27 
    26 from cubicweb.cwconfig import CubicWebConfiguration
    28 from cubicweb.cwconfig import CubicWebConfiguration
    27 from cubicweb.cwctl import ListCommand
    29 from cubicweb.cwctl import ListCommand
    28 from cubicweb.devtools.testlib import CubicWebTC
    30 from cubicweb.devtools.testlib import CubicWebTC
    29 from cubicweb.server.migractions import ServerMigrationHelper
    31 from cubicweb.server.migractions import ServerMigrationHelper
    30 
    32 
       
    33 import unittest_cwconfig
       
    34 
    31 
    35 
    32 class CubicWebCtlTC(unittest.TestCase):
    36 class CubicWebCtlTC(unittest.TestCase):
       
    37 
       
    38     setUpClass = unittest_cwconfig.CubicWebConfigurationTC.setUpClass
       
    39     tearDownClass = unittest_cwconfig.CubicWebConfigurationTC.tearDownClass
    33 
    40 
    34     def setUp(self):
    41     def setUp(self):
    35         self.stream = BytesIO() if PY2 else StringIO()
    42         self.stream = BytesIO() if PY2 else StringIO()
    36         sys.stdout = self.stream
    43         sys.stdout = self.stream
    37 
    44 
    38     def tearDown(self):
    45     def tearDown(self):
    39         sys.stdout = sys.__stdout__
    46         sys.stdout = sys.__stdout__
    40 
    47 
    41     def test_list(self):
    48     @patch('pkg_resources.iter_entry_points', side_effect=unittest_cwconfig.iter_entry_points)
       
    49     def test_list(self, mock_iter_entry_points):
    42         ListCommand(None).run([])
    50         ListCommand(None).run([])
       
    51         self.assertNotIn('cubicweb_', self.stream.getvalue())
       
    52         mock_iter_entry_points.assert_called_once_with(
       
    53             group='cubicweb.cubes', name=None)
    43 
    54 
    44     def test_list_configurations(self):
    55     def test_list_configurations(self):
    45         ListCommand(None).run(['configurations'])
    56         ListCommand(None).run(['configurations'])
    46         configs = [l[2:].strip() for l in self.stream.getvalue().splitlines()
    57         configs = [l[2:].strip() for l in self.stream.getvalue().splitlines()
    47                    if l.startswith('* ')]
    58                    if l.startswith('* ')]