1# Copyright 2021 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Tests for GoldfishRemoteImageRemoteInstance.""" 15 16import unittest 17 18from unittest import mock 19 20from acloud.create import avd_spec 21from acloud.create import create 22from acloud.internal import constants 23from acloud.internal.lib import driver_test_lib 24from acloud.internal.lib import utils 25from acloud.public.actions import create_goldfish_action 26 27class GoldfishRemoteImageRemoteInstanceTest(driver_test_lib.BaseDriverTest): 28 """Test GoldfishRemoteImageRemoteInstance method.""" 29 30 # pylint: disable=no-member 31 def testRun(self): 32 """Test Create AVD of goldfish remote image remote instance.""" 33 args = mock.MagicMock() 34 args.skip_pre_run_check = True 35 spec = mock.MagicMock() 36 spec.avd_type = constants.TYPE_GF 37 spec.instance_type = constants.INSTANCE_TYPE_REMOTE 38 spec.image_source = constants.IMAGE_SRC_REMOTE 39 spec.connect_vnc = False 40 self.Patch(avd_spec, "AVDSpec", return_value=spec) 41 self.Patch(create_goldfish_action, 42 "CreateDevices") 43 create.Run(args) 44 create_goldfish_action.CreateDevices.assert_called_once() 45 46 spec.connect_vnc = True 47 self.Patch(avd_spec, "AVDSpec", return_value=spec) 48 self.Patch(utils, "LaunchVNCFromReport") 49 create.Run(args) 50 utils.LaunchVNCFromReport.assert_called_once() 51 52 53if __name__ == '__main__': 54 unittest.main() 55