Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2016 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | """Tests for acloud.public.config.""" |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 18 | import unittest |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 19 | import os |
Kevin Cheng | 4fce0bc | 2018-08-13 11:51:34 -0700 | [diff] [blame] | 20 | import tempfile |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 21 | import mock |
| 22 | |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 23 | import six |
| 24 | |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 25 | # pylint: disable=no-name-in-module,import-error |
Sam Chiu | 7de3b23 | 2018-12-06 19:45:52 +0800 | [diff] [blame] | 26 | from acloud import errors |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 27 | from acloud.internal.proto import internal_config_pb2 |
| 28 | from acloud.internal.proto import user_config_pb2 |
| 29 | from acloud.public import config |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 30 | |
| 31 | |
| 32 | class AcloudConfigManagerTest(unittest.TestCase): |
| 33 | """Test acloud configuration manager.""" |
| 34 | |
| 35 | USER_CONFIG = """ |
| 36 | service_account_name: "fake@developer.gserviceaccount.com" |
| 37 | service_account_private_key_path: "/path/to/service/account/key" |
xingdai | 8a00d46 | 2018-07-30 14:24:48 -0700 | [diff] [blame] | 38 | service_account_json_private_key_path: "/path/to/service/account/json_key" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 39 | project: "fake-project" |
| 40 | zone: "us-central1-f" |
| 41 | machine_type: "n1-standard-1" |
| 42 | network: "default" |
| 43 | ssh_private_key_path: "/path/to/ssh/key" |
| 44 | storage_bucket_name: "fake_bucket" |
| 45 | orientation: "portrait" |
| 46 | resolution: "1200x1200x1200x1200" |
| 47 | client_id: "fake_client_id" |
| 48 | client_secret: "fake_client_secret" |
cylan | d370db2 | 2019-07-17 16:04:00 +0800 | [diff] [blame] | 49 | extra_args_ssh_tunnel: "fake_extra_args_ssh_tunnel" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 50 | metadata_variable { |
| 51 | key: "metadata_1" |
| 52 | value: "metadata_value_1" |
| 53 | } |
Sam Chiu | c64f343 | 2018-08-17 11:19:06 +0800 | [diff] [blame] | 54 | hw_property: "cpu:3,resolution:1080x1920,dpi:480,memory:4g,disk:10g" |
Kevin Cheng | c330f6f | 2019-05-13 09:32:42 -0700 | [diff] [blame] | 55 | extra_scopes: "scope1" |
| 56 | extra_scopes: "scope2" |
Shao-Chuan Lee | 2600526 | 2020-09-10 21:51:33 +0900 | [diff] [blame] | 57 | betty_image: "fake_betty_image" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 58 | """ |
| 59 | |
| 60 | INTERNAL_CONFIG = """ |
| 61 | min_machine_size: "n1-standard-1" |
| 62 | disk_image_name: "avd-system.tar.gz" |
| 63 | disk_image_mime_type: "application/x-tar" |
| 64 | disk_image_extension: ".tar.gz" |
| 65 | disk_raw_image_name: "disk.raw" |
| 66 | disk_raw_image_extension: ".img" |
| 67 | creds_cache_file: ".fake_oauth2.dat" |
| 68 | user_agent: "fake_user_agent" |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 69 | kernel_build_target: "kernel" |
| 70 | emulator_build_target: "sdk_tools_linux" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 71 | |
| 72 | default_usr_cfg { |
| 73 | machine_type: "n1-standard-1" |
| 74 | network: "default" |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 75 | stable_host_image_name: "fake_stable_host_image_name" |
| 76 | stable_host_image_project: "fake_stable_host_image_project" |
| 77 | stable_goldfish_host_image_name: "fake_stable_goldfish_host_image_name" |
| 78 | stable_goldfish_host_image_project: "fake_stable_goldfish_host_image_project" |
Kevin Cheng | f13e8be | 2019-05-10 14:17:32 -0700 | [diff] [blame] | 79 | instance_name_pattern: "fake_instance_name_pattern" |
Richard Fung | 97503b2 | 2019-02-06 13:43:38 -0800 | [diff] [blame] | 80 | stable_cheeps_host_image_name: "fake_stable_cheeps_host_image_name" |
| 81 | stable_cheeps_host_image_project: "fake_stable_cheeps_host_image_project" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 82 | metadata_variable { |
| 83 | key: "metadata_1" |
| 84 | value: "metadata_value_1" |
| 85 | } |
| 86 | |
| 87 | metadata_variable { |
| 88 | key: "metadata_2" |
| 89 | value: "metadata_value_2" |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | device_resolution_map { |
| 94 | key: "nexus5" |
| 95 | value: "1080x1920x32x480" |
| 96 | } |
| 97 | |
| 98 | device_default_orientation_map { |
| 99 | key: "nexus5" |
| 100 | value: "portrait" |
| 101 | } |
| 102 | |
| 103 | valid_branch_and_min_build_id { |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 104 | key: "aosp-master" |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 105 | value: 0 |
| 106 | } |
Sam Chiu | 58dad6e | 2018-08-27 19:50:33 +0800 | [diff] [blame] | 107 | |
| 108 | common_hw_property_map { |
| 109 | key: "phone" |
Sam Chiu | c64f343 | 2018-08-17 11:19:06 +0800 | [diff] [blame] | 110 | value: "cpu:2,resolution:1080x1920,dpi:420,memory:4g,disk:8g" |
Sam Chiu | 58dad6e | 2018-08-27 19:50:33 +0800 | [diff] [blame] | 111 | } |
herbertxue | 908bfa8 | 2020-11-24 17:49:26 +0800 | [diff] [blame] | 112 | |
| 113 | common_hw_property_map { |
| 114 | key: "auto" |
| 115 | value: "cpu:4,resolution:1280x800,dpi:160,memory:4g" |
| 116 | } |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 117 | """ |
| 118 | |
| 119 | def setUp(self): |
| 120 | self.config_file = mock.MagicMock() |
herbertxue | 908bfa8 | 2020-11-24 17:49:26 +0800 | [diff] [blame] | 121 | # initial config with test config. |
| 122 | self.config_file.read.return_value = self.INTERNAL_CONFIG |
| 123 | internal_cfg = config.AcloudConfigManager.LoadConfigFromProtocolBuffer( |
| 124 | self.config_file, internal_config_pb2.InternalConfig) |
| 125 | self.config_file.read.return_value = self.USER_CONFIG |
| 126 | usr_cfg = config.AcloudConfigManager.LoadConfigFromProtocolBuffer( |
| 127 | self.config_file, user_config_pb2.UserConfig) |
| 128 | self.cfg = config.AcloudConfig(usr_cfg, internal_cfg) |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 129 | |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 130 | # pylint: disable=no-member |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 131 | def testLoadUserConfig(self): |
| 132 | """Test loading user config.""" |
| 133 | self.config_file.read.return_value = self.USER_CONFIG |
| 134 | cfg = config.AcloudConfigManager.LoadConfigFromProtocolBuffer( |
| 135 | self.config_file, user_config_pb2.UserConfig) |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 136 | self.assertEqual(cfg.service_account_name, |
| 137 | "fake@developer.gserviceaccount.com") |
| 138 | self.assertEqual(cfg.service_account_private_key_path, |
| 139 | "/path/to/service/account/key") |
xingdai | 8a00d46 | 2018-07-30 14:24:48 -0700 | [diff] [blame] | 140 | self.assertEqual(cfg.service_account_json_private_key_path, |
| 141 | "/path/to/service/account/json_key") |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 142 | self.assertEqual(cfg.project, "fake-project") |
| 143 | self.assertEqual(cfg.zone, "us-central1-f") |
| 144 | self.assertEqual(cfg.machine_type, "n1-standard-1") |
| 145 | self.assertEqual(cfg.network, "default") |
| 146 | self.assertEqual(cfg.ssh_private_key_path, "/path/to/ssh/key") |
| 147 | self.assertEqual(cfg.storage_bucket_name, "fake_bucket") |
| 148 | self.assertEqual(cfg.orientation, "portrait") |
| 149 | self.assertEqual(cfg.resolution, "1200x1200x1200x1200") |
| 150 | self.assertEqual(cfg.client_id, "fake_client_id") |
| 151 | self.assertEqual(cfg.client_secret, "fake_client_secret") |
cylan | d370db2 | 2019-07-17 16:04:00 +0800 | [diff] [blame] | 152 | self.assertEqual(cfg.extra_args_ssh_tunnel, "fake_extra_args_ssh_tunnel") |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 153 | self.assertEqual( |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 154 | {key: val for key, val in six.iteritems(cfg.metadata_variable)}, |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 155 | {"metadata_1": "metadata_value_1"}) |
Sam Chiu | 58dad6e | 2018-08-27 19:50:33 +0800 | [diff] [blame] | 156 | self.assertEqual(cfg.hw_property, |
Sam Chiu | c64f343 | 2018-08-17 11:19:06 +0800 | [diff] [blame] | 157 | "cpu:3,resolution:1080x1920,dpi:480,memory:4g," |
| 158 | "disk:10g") |
Kevin Cheng | c330f6f | 2019-05-13 09:32:42 -0700 | [diff] [blame] | 159 | self.assertEqual(cfg.extra_scopes, ["scope1", "scope2"]) |
Shao-Chuan Lee | 2600526 | 2020-09-10 21:51:33 +0900 | [diff] [blame] | 160 | self.assertEqual(cfg.betty_image, "fake_betty_image") |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 161 | |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 162 | # pylint: disable=protected-access |
Kevin Cheng | 99cf3d3 | 2018-10-05 02:09:21 -0700 | [diff] [blame] | 163 | @mock.patch("os.makedirs") |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 164 | @mock.patch("os.path.exists") |
Kevin Cheng | 99cf3d3 | 2018-10-05 02:09:21 -0700 | [diff] [blame] | 165 | def testLoadUserConfigLogic(self, mock_file_exist, _mock_makedirs): |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 166 | """Test load user config logic. |
| 167 | |
| 168 | Load user config with some special design. |
| 169 | 1. User specified user config: |
| 170 | If user config didn't exist: Raise exception. |
| 171 | 2. User didn't specify user config, use default config: |
| 172 | If default config didn't exist: Initialize empty data. |
| 173 | """ |
| 174 | config_specify = config.AcloudConfigManager(self.config_file) |
| 175 | self.config_file.read.return_value = self.USER_CONFIG |
herbertxue | 34776bb | 2018-07-03 21:57:48 +0800 | [diff] [blame] | 176 | self.assertEqual(config_specify.user_config_path, self.config_file) |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 177 | mock_file_exist.return_value = False |
| 178 | with self.assertRaises(errors.ConfigError): |
| 179 | config_specify.Load() |
| 180 | # Test default config |
| 181 | config_unspecify = config.AcloudConfigManager(None) |
| 182 | cfg = config_unspecify.Load() |
herbertxue | 34776bb | 2018-07-03 21:57:48 +0800 | [diff] [blame] | 183 | self.assertEqual(config_unspecify.user_config_path, |
Kevin Cheng | 4fce0bc | 2018-08-13 11:51:34 -0700 | [diff] [blame] | 184 | config.GetDefaultConfigFile()) |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 185 | self.assertEqual(cfg.project, "") |
| 186 | self.assertEqual(cfg.zone, "") |
Kevin Cheng | 4fce0bc | 2018-08-13 11:51:34 -0700 | [diff] [blame] | 187 | |
| 188 | # Test default user config exist |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 189 | mock_file_exist.return_value = True |
Kevin Cheng | 4fce0bc | 2018-08-13 11:51:34 -0700 | [diff] [blame] | 190 | # Write the config data into a tmp file and have GetDefaultConfigFile |
| 191 | # return that. |
| 192 | _, temp_cfg_file_path = tempfile.mkstemp() |
| 193 | with open(temp_cfg_file_path, "w") as cfg_file: |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 194 | cfg_file.writelines(self.USER_CONFIG) |
Kevin Cheng | 4fce0bc | 2018-08-13 11:51:34 -0700 | [diff] [blame] | 195 | default_patcher = mock.patch.object(config, "GetDefaultConfigFile", |
| 196 | return_value=temp_cfg_file_path) |
| 197 | default_patcher.start() |
| 198 | try: |
| 199 | config_exist = config.AcloudConfigManager(None) |
| 200 | cfg = config_exist.Load() |
| 201 | self.assertEqual(cfg.project, "fake-project") |
| 202 | self.assertEqual(cfg.zone, "us-central1-f") |
| 203 | self.assertEqual(cfg.client_id, "fake_client_id") |
| 204 | self.assertEqual(cfg.client_secret, "fake_client_secret") |
| 205 | finally: |
| 206 | # Delete tmp file |
| 207 | os.remove(temp_cfg_file_path) |
| 208 | default_patcher.stop() |
herbertxue | 18c9b26 | 2018-07-12 19:14:49 +0800 | [diff] [blame] | 209 | |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 210 | def testLoadInternalConfig(self): |
| 211 | """Test loading internal config.""" |
| 212 | self.config_file.read.return_value = self.INTERNAL_CONFIG |
| 213 | cfg = config.AcloudConfigManager.LoadConfigFromProtocolBuffer( |
| 214 | self.config_file, internal_config_pb2.InternalConfig) |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 215 | self.assertEqual(cfg.min_machine_size, "n1-standard-1") |
| 216 | self.assertEqual(cfg.disk_image_name, "avd-system.tar.gz") |
| 217 | self.assertEqual(cfg.disk_image_mime_type, "application/x-tar") |
| 218 | self.assertEqual(cfg.disk_image_extension, ".tar.gz") |
| 219 | self.assertEqual(cfg.disk_raw_image_name, "disk.raw") |
| 220 | self.assertEqual(cfg.disk_raw_image_extension, ".img") |
| 221 | self.assertEqual(cfg.creds_cache_file, ".fake_oauth2.dat") |
| 222 | self.assertEqual(cfg.user_agent, "fake_user_agent") |
| 223 | self.assertEqual(cfg.default_usr_cfg.machine_type, "n1-standard-1") |
| 224 | self.assertEqual(cfg.default_usr_cfg.network, "default") |
| 225 | self.assertEqual({ |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 226 | key: val |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 227 | for key, val in six.iteritems(cfg.default_usr_cfg.metadata_variable) |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 228 | }, { |
| 229 | "metadata_1": "metadata_value_1", |
| 230 | "metadata_2": "metadata_value_2" |
| 231 | }) |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 232 | self.assertEqual( |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 233 | {key: val for key, val in six.iteritems(cfg.device_resolution_map)}, |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 234 | {"nexus5": "1080x1920x32x480"}) |
| 235 | device_resolution = { |
| 236 | key: val |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 237 | for key, val in six.iteritems(cfg.device_default_orientation_map) |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 238 | } |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 239 | self.assertEqual(device_resolution, {"nexus5": "portrait"}) |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 240 | valid_branch_and_min_build_id = { |
| 241 | key: val |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 242 | for key, val in six.iteritems(cfg.valid_branch_and_min_build_id) |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 243 | } |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 244 | self.assertEqual(valid_branch_and_min_build_id, {"aosp-master": 0}) |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 245 | self.assertEqual(cfg.default_usr_cfg.stable_host_image_name, |
| 246 | "fake_stable_host_image_name") |
| 247 | self.assertEqual(cfg.default_usr_cfg.stable_host_image_project, |
| 248 | "fake_stable_host_image_project") |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 249 | self.assertEqual(cfg.kernel_build_target, "kernel") |
| 250 | |
| 251 | # Emulator related |
Sam Chiu | 46ea311 | 2018-05-18 10:47:52 +0800 | [diff] [blame] | 252 | self.assertEqual(cfg.default_usr_cfg.stable_goldfish_host_image_name, |
| 253 | "fake_stable_goldfish_host_image_name") |
| 254 | self.assertEqual(cfg.default_usr_cfg.stable_goldfish_host_image_project, |
| 255 | "fake_stable_goldfish_host_image_project") |
Kevin Cheng | b596388 | 2018-05-09 00:06:27 -0700 | [diff] [blame] | 256 | self.assertEqual(cfg.emulator_build_target, "sdk_tools_linux") |
Kevin Cheng | f13e8be | 2019-05-10 14:17:32 -0700 | [diff] [blame] | 257 | self.assertEqual(cfg.default_usr_cfg.instance_name_pattern, |
| 258 | "fake_instance_name_pattern") |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 259 | |
Richard Fung | 97503b2 | 2019-02-06 13:43:38 -0800 | [diff] [blame] | 260 | # Cheeps related |
| 261 | self.assertEqual(cfg.default_usr_cfg.stable_cheeps_host_image_name, |
| 262 | "fake_stable_cheeps_host_image_name") |
| 263 | self.assertEqual(cfg.default_usr_cfg.stable_cheeps_host_image_project, |
| 264 | "fake_stable_cheeps_host_image_project") |
| 265 | |
Sam Chiu | 58dad6e | 2018-08-27 19:50:33 +0800 | [diff] [blame] | 266 | # hw property |
| 267 | self.assertEqual( |
chojoyce | 35556da | 2019-10-25 16:02:36 +0800 | [diff] [blame] | 268 | {key: val for key, val in six.iteritems(cfg.common_hw_property_map)}, |
herbertxue | 908bfa8 | 2020-11-24 17:49:26 +0800 | [diff] [blame] | 269 | {"phone": "cpu:2,resolution:1080x1920,dpi:420,memory:4g,disk:8g", |
| 270 | "auto": "cpu:4,resolution:1280x800,dpi:160,memory:4g"}) |
Sam Chiu | 58dad6e | 2018-08-27 19:50:33 +0800 | [diff] [blame] | 271 | |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 272 | def testLoadConfigFails(self): |
| 273 | """Test loading a bad file.""" |
| 274 | self.config_file.read.return_value = "malformed text" |
| 275 | with self.assertRaises(errors.ConfigError): |
| 276 | config.AcloudConfigManager.LoadConfigFromProtocolBuffer( |
| 277 | self.config_file, internal_config_pb2.InternalConfig) |
| 278 | |
herbertxue | 9392437 | 2021-02-05 14:11:01 +0800 | [diff] [blame^] | 279 | def testOverrideWithArgs(self): |
| 280 | """Test OverrideWithArgs.""" |
herbertxue | ffbcbc2 | 2020-07-07 14:35:34 +0800 | [diff] [blame] | 281 | # test override zone. |
herbertxue | 908bfa8 | 2020-11-24 17:49:26 +0800 | [diff] [blame] | 282 | self.cfg.zone = "us-central1-f" |
herbertxue | ffbcbc2 | 2020-07-07 14:35:34 +0800 | [diff] [blame] | 283 | args = mock.MagicMock() |
| 284 | args.which = "create" |
| 285 | args.flavor = "phone" |
| 286 | args.zone = "us-central1-b" |
herbertxue | 908bfa8 | 2020-11-24 17:49:26 +0800 | [diff] [blame] | 287 | self.cfg.OverrideWithArgs(args) |
| 288 | self.assertEqual(self.cfg.zone, "us-central1-b") |
| 289 | |
| 290 | def testGetDefaultHwProperty(self): |
| 291 | """Test GetDefaultHwProperty.""" |
| 292 | # test with "phone" flavor |
| 293 | expected = "cpu:2,resolution:1080x1920,dpi:420,memory:4g,disk:8g" |
| 294 | self.assertEqual(expected, self.cfg.GetDefaultHwProperty("phone")) |
| 295 | |
| 296 | # test with "auto" flavor |
| 297 | expected = "cpu:4,resolution:1280x800,dpi:160,memory:4g" |
| 298 | self.assertEqual(expected, self.cfg.GetDefaultHwProperty("auto")) |
herbertxue | ffbcbc2 | 2020-07-07 14:35:34 +0800 | [diff] [blame] | 299 | |
Tri Vo | 29ac182 | 2016-10-01 17:06:29 -0700 | [diff] [blame] | 300 | |
| 301 | if __name__ == "__main__": |
| 302 | unittest.main() |