Example #1
0
 def test_failed(self, mock_is_systemctl):
     mock_is_systemctl.return_value = True
     self.mock_runner.run.return_value = ("stdout", "failed", 1)
     self.assertEqual(lib.get_systemd_services(self.mock_runner), [])
     self.assertEqual(mock_is_systemctl.call_count, 1)
     self.mock_runner.run.assert_called_once_with(
         [_systemctl, "list-unit-files", "--full"])
Example #2
0
 def test_failed(self, mock_is_systemctl):
     mock_is_systemctl.return_value = True
     self.mock_runner.run.return_value = ("failed", 1)
     self.assertEqual(lib.get_systemd_services(self.mock_runner), [])
     self.assertEqual(mock_is_systemctl.call_count, 1)
     self.mock_runner.run.assert_called_once_with(
         ["systemctl", "list-unit-files", "--full"]
     )
Example #3
0
    def test_success(self, mock_is_systemctl):
        mock_is_systemctl.return_value = True
        self.mock_runner.run.return_value = (outdent("""\
            pcsd.service                                disabled
            sbd.service                                 enabled
            pacemaker.service                           enabled

            3 unit files listed.
            """), "", 0)
        self.assertEqual(lib.get_systemd_services(self.mock_runner),
                         ["pcsd", "sbd", "pacemaker"])
        self.assertEqual(mock_is_systemctl.call_count, 1)
        self.mock_runner.run.assert_called_once_with(
            [_systemctl, "list-unit-files", "--full"])
Example #4
0
    def test_success(self, mock_is_systemctl):
        mock_is_systemctl.return_value = True
        self.mock_runner.run.return_value = ("""\
pcsd.service                                disabled
sbd.service                                 enabled
pacemaker.service                           enabled

3 unit files listed.
""", 0)
        self.assertEqual(
            lib.get_systemd_services(self.mock_runner),
            ["pcsd", "sbd", "pacemaker"]
        )
        self.assertEqual(mock_is_systemctl.call_count, 1)
        self.mock_runner.run.assert_called_once_with(
            ["systemctl", "list-unit-files", "--full"]
        )
Example #5
0
 def test_not_systemd(self, mock_is_systemctl):
     mock_is_systemctl.return_value = False
     self.assertEqual(lib.get_systemd_services(self.mock_runner), [])
     mock_is_systemctl.assert_called_once_with()
     self.mock_runner.assert_not_called()
Example #6
0
 def test_not_systemd(self, mock_is_systemctl):
     mock_is_systemctl.return_value = False
     self.mock_runner.run.return_value = ("", 0)
     self.assertEqual(lib.get_systemd_services(self.mock_runner), [])
     self.assertEqual(mock_is_systemctl.call_count, 1)
     self.assertEqual(self.mock_runner.call_count, 0)
Example #7
0
 def test_not_systemd(self, mock_is_systemctl):
     mock_is_systemctl.return_value = False
     self.assertEqual(lib.get_systemd_services(self.mock_runner), [])
     mock_is_systemctl.assert_called_once_with()
     self.mock_runner.assert_not_called()