예제 #1
0
 def test_terminate_started_server(self):
     """
     Terminate a server with a 'started' status
     """
     server = StartedOpenStackServerFactory()
     server.terminate()
     self.assertEqual(server.status, server.TERMINATED)
     server.os_server.delete.assert_called_once_with()
예제 #2
0
 def test_terminate_started_server(self):
     """
     Terminate a server with a 'started' status
     """
     server = StartedOpenStackServerFactory()
     server.terminate()
     self.assertEqual(server.status, ServerStatus.Terminated)
     self.assertEqual(server.progress, ServerProgress.Success)
     server.os_server.delete.assert_called_once_with()
예제 #3
0
    def test_terminate_server_not_found(self):
        """
        Terminate a server for which the corresponding VM doesn't exist anymore
        """
        server = StartedOpenStackServerFactory()

        def raise_not_found(): #pylint: disable=missing-docstring
            raise novaclient.exceptions.NotFound('not-found')
        server.os_server.delete.side_effect = raise_not_found
        server.log = Mock()

        server.terminate()
        server.log.assert_any_call('exception', AnyStringMatching('Error while attempting to terminate server'))
        self.assertEqual(server.status, server.TERMINATED)
예제 #4
0
    def test_terminate_server_not_found(self):
        """
        Terminate a server for which the corresponding VM doesn't exist anymore
        """
        server = StartedOpenStackServerFactory()

        def raise_not_found(): #pylint: disable=missing-docstring
            raise novaclient.exceptions.NotFound('not-found')
        server.os_server.delete.side_effect = raise_not_found
        server.logger = Mock()
        mock_logger = server.logger

        server.terminate()
        mock_logger.error.assert_called_once_with(AnyStringMatching('Error while attempting to terminate server'))
        self.assertEqual(server.status, ServerStatus.Terminated)
        self.assertEqual(server.progress, ServerProgress.Success)