예제 #1
0
    def test_cloud_hard_reboot(self, mock_start_instance, mock_stop_instance,
                               mock_set_instance_ip):
        """Test start instance if stopped method."""
        mock_stop_instance.return_value = None
        mock_start_instance.return_value = None
        mock_set_instance_ip.return_value = None

        cloud = IpaCloud(*args, **self.kwargs)
        cloud.instance_ip = '0.0.0.0'
        cloud.hard_reboot_instance()

        assert mock_stop_instance.call_count == 1
        assert mock_start_instance.call_count == 1
        assert mock_set_instance_ip.call_count == 1
예제 #2
0
    def test_cloud_get_ssh_client(self, mock_get_ssh_client):
        """Test get ssh client method."""
        cloud = IpaCloud(*args, **self.kwargs)

        cloud.instance_ip = '127.0.0.1'
        cloud.ssh_user = '******'
        cloud.ssh_private_key_file = 'tests/data/ida_test'

        client = MagicMock()
        mock_get_ssh_client.return_value = client

        val = cloud._get_ssh_client()
        assert val == client
        assert mock_get_ssh_client.call_count == 1

        ipa_utils.clear_cache()