Ejemplo n.º 1
0
 def test_service_not_running_stop_hook(self, mock_log, mock_close_port,
                                        mock_service_stop, mock_apt_purge):
     with patch_service_running(False):
         with patch_hook_name('stop'):
             serviceutils.service_stop(self.port, self.service_name)
     self.assertFalse(mock_service_stop.called)
     mock_close_port.assert_called_once_with(self.port)
Ejemplo n.º 2
0
 def test_customized_port(self, mock_log, mock_close_port,
                          mock_service_stop, mock_apt_purge):
     port = 4747
     with patch_service_running(False):
         with patch_hook_name('stop'):
             serviceutils.service_stop(port, self.service_name)
     mock_close_port.assert_called_once_with(port)
Ejemplo n.º 3
0
 def test_cleaning_up(self, mock_log, mock_close_port, mock_service_stop,
                      mock_apt_purge):
     port = 4747
     with patch_service_running(False):
         with patch_hook_name('stop'):
             serviceutils.service_stop(port, self.service_name)
     mock_log.assert_called_once_with('Removing system packages.')
     mock_apt_purge.assert_called_once_with(settings.PACKAGES)
Ejemplo n.º 4
0
 def test_service_not_running_other_hook(self, mock_log, mock_close_port,
                                         mock_service_stop, mock_apt_purge):
     with patch_service_running(False):
         with patch_hook_name('config-changed'):
             serviceutils.service_stop(self.port, self.service_name)
     self.assertFalse(mock_service_stop.called)
     self.assertFalse(mock_log.called)
     self.assertFalse(mock_close_port.called)
     self.assertFalse(mock_apt_purge.called)
Ejemplo n.º 5
0
 def test_service_running_stop_hook(self, mock_log, mock_close_port,
                                    mock_service_stop, mock_apt_purge):
     with patch_service_running(True):
         with patch_hook_name('stop'):
             serviceutils.service_stop(self.port, self.service_name)
     mock_service_stop.assert_called_once_with(settings.SERVICE_NAME)
     self.assertEqual(2, mock_log.call_count)
     mock_log.assert_has_calls([
         mock.call('Stopping service {}.'.format(self.service_name)),
         mock.call('Removing system packages.')
     ])
     mock_close_port.assert_called_once_with(self.port)