Пример #1
0
    def test_catch_keyboard_exception(self):
        """
        Verify that the KeyboardInterrupt is propagated by the run() method.
        ./bin/stratis contains a try block at the outermost level which
        then catches the KeyboardInterrupt and exits with an error message.
        The KeyboardInterrupt is most likely raised in the dbus-python
        method which is actually communicating on the D-Bus, but it is
        fairly difficult to get at that method. Instead settle for getting
        at the calling method generated by dbus-python-client-gen.
        """

        def raise_keyboard_interrupt(_):
            """
            Just raise the interrupt.
            """
            raise KeyboardInterrupt()

        # pylint: disable=import-outside-toplevel
        from stratis_cli._actions import _data

        # pylint: disable=protected-access
        stratis_cli._actions._data.Manager.Properties.Version.Get = (
            raise_keyboard_interrupt
        )

        with self.assertRaises(KeyboardInterrupt):
            stratis_cli.run()(["daemon", "version"])
Пример #2
0
 def setUp(self):
     """
     Start the stratisd daemon with the simulator.
     """
     self._service = Service()
     self._service.setUp()
     time.sleep(1)
     command_line = \
        ['pool', 'create', self._POOLNAME] + \
        [d.device_node for d in _device_list(_DEVICES, 1)]
     all(run(command_line))
     command_line = \
        ['filesystem', 'create', self._POOLNAME, self._VOLNAME]
     all(run(command_line))
Пример #3
0
        time.sleep(1)

    def tearDown(self):
        """
        Stop the stratisd simulator and daemon.
        """
        # pylint: disable=no-member
        self._stratisd.terminate()
        self._stratisd.wait()


class SimTestCase(unittest.TestCase):
    """
    A SimTestCase must always start and stop stratisd (simulator vesion).
    """
    def setUp(self):
        """
        Start the stratisd daemon with the simulator.
        """
        self._service = _Service()
        self._service.setUp()

    def tearDown(self):
        """
        Stop the stratisd simulator and daemon.
        """
        self._service.tearDown()


RUNNER = run()