Lines Matching refs:self
54 def setUp(self): argument
56 super(CreateGoldfishActionTest, self).setUp()
57 self.build_client = mock.MagicMock()
58 self.Patch(
61 return_value=self.build_client)
62 self.compute_client = mock.MagicMock()
63 self.Patch(
66 return_value=self.compute_client)
67 self.Patch(
70 return_value=self.compute_client)
71 self.Patch(auth, "CreateCredentials", return_value=mock.MagicMock())
73 self.avd_spec = mock.MagicMock()
74 self.avd_spec.cfg = self._CreateCfg()
75 self.avd_spec.remote_image = {constants.BUILD_ID: self.BUILD_ID,
76 constants.BUILD_BRANCH: self.BRANCH,
77 constants.BUILD_TARGET: self.BUILD_TARGET}
78 self.avd_spec.emulator_build_id = self.EMULATOR_BUILD_ID
79 self.avd_spec.gpu = self.GPU
80 self.avd_spec.serial_log_file = None
81 self.avd_spec.autoconnect = False
83 def _CreateCfg(self): argument
91 cfg.stable_goldfish_host_image_name = self.GOLDFISH_HOST_IMAGE_NAME
92 cfg.stable_goldfish_host_image_project = self.GOLDFISH_HOST_IMAGE_PROJECT
93 cfg.emulator_build_target = self.EMULATOR_BUILD_TARGET
94 cfg.extra_data_disk_size_gb = self.EXTRA_DATA_DISK_GB
95 cfg.extra_scopes = self.EXTRA_SCOPES
96 cfg.launch_args = self.LAUNCH_ARGS
99 def testCreateDevices(self): argument
101 cfg = self._CreateCfg()
105 self.Patch(uuid, "uuid4", return_value=fake_uuid)
108 self.compute_client.GetInstanceIP.return_value = self.IP
109 self.compute_client.GenerateImageName.return_value = self.IMAGE
110 self.compute_client.GenerateInstanceName.return_value = self.INSTANCE
113 self.build_client.GetBuildInfo.side_effect = [
115 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
117 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
118 self.EMULATOR_BUILD_TARGET, None),
120 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
121 self.KERNEL_BUILD_TARGET, None)]
127 none_avd_spec, cfg, build_target=self.BUILD_TARGET,
128 build_id=self.BUILD_ID, emulator_build_id=self.EMULATOR_BUILD_ID,
129 gpu=self.GPU,
130 kernel_branch=self.KERNEL_BRANCH,
131 kernel_build_id=self.KERNEL_BUILD_ID,
132 kernel_build_target=self.KERNEL_BUILD_TARGET)
135 self.compute_client.CreateInstance.assert_called_with(
136 instance=self.INSTANCE,
137 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
138 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
139 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
140 build_target=self.BUILD_TARGET,
141 branch=self.BRANCH,
142 build_id=self.BUILD_ID,
143 emulator_branch=self.EMULATOR_BRANCH,
144 emulator_build_id=self.EMULATOR_BUILD_ID,
145 kernel_branch=self.KERNEL_BRANCH,
146 kernel_build_id=self.KERNEL_BUILD_ID,
147 kernel_build_target=self.KERNEL_BUILD_TARGET,
148 gpu=self.GPU,
150 extra_scopes=self.EXTRA_SCOPES,
152 launch_args=self.LAUNCH_ARGS)
154 self.assertEqual(report.data, {
157 "instance_name": self.INSTANCE,
158 "ip": self.IP.external,
159 "branch": self.BRANCH,
160 "build_id": self.BUILD_ID,
161 "build_target": self.BUILD_TARGET,
162 "emulator_branch": self.EMULATOR_BRANCH,
163 "emulator_build_id": self.EMULATOR_BUILD_ID,
164 "emulator_build_target": self.EMULATOR_BUILD_TARGET,
165 "kernel_branch": self.KERNEL_BRANCH,
166 "kernel_build_id": self.KERNEL_BUILD_ID,
167 "kernel_build_target": self.KERNEL_BUILD_TARGET,
171 self.assertEqual(report.command, "create_gf")
172 self.assertEqual(report.status, "SUCCESS")
175 self.build_client.GetBranch.side_effect = [
176 self.BRANCH, self.EMULATOR_BRANCH
180 self.build_client.GetBuildInfo.side_effect = [
182 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
184 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
185 self.EMULATOR_BUILD_TARGET, None),
187 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
188 self.KERNEL_BUILD_TARGET, None)]
190 report = create_goldfish_action.CreateDevices(avd_spec=self.avd_spec)
192 self.compute_client.CreateInstance.assert_called_with(
193 instance=self.INSTANCE,
194 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
195 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
196 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
197 build_target=self.BUILD_TARGET,
198 branch=self.BRANCH,
199 build_id=self.BUILD_ID,
200 emulator_branch=self.EMULATOR_BRANCH,
201 emulator_build_id=self.EMULATOR_BUILD_ID,
202 kernel_branch=self.KERNEL_BRANCH,
203 kernel_build_id=self.KERNEL_BUILD_ID,
204 kernel_build_target=self.KERNEL_BUILD_TARGET,
205 gpu=self.GPU,
206 avd_spec=self.avd_spec,
207 extra_scopes=self.EXTRA_SCOPES,
209 launch_args=self.LAUNCH_ARGS)
211 def testCreateDevicesWithoutBuildId(self): argument
213 cfg = self._CreateCfg()
217 self.Patch(uuid, "uuid4", return_value=fake_uuid)
220 self.compute_client.GetInstanceIP.return_value = self.IP
221 self.compute_client.GenerateImageName.return_value = self.IMAGE
222 self.compute_client.GenerateInstanceName.return_value = self.INSTANCE
225 self.build_client.GetBuildInfo.side_effect = [
227 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
229 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
230 self.EMULATOR_BUILD_TARGET, None),
232 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
233 self.KERNEL_BUILD_TARGET, None)]
236 self.Patch(
239 return_value=self.BUILD_ID)
246 build_target=self.BUILD_TARGET,
248 emulator_build_id=self.EMULATOR_BUILD_ID,
250 gpu=self.GPU,
252 kernel_branch=self.KERNEL_BRANCH,
253 kernel_build_id=self.KERNEL_BUILD_ID,
254 kernel_build_target=self.KERNEL_BUILD_TARGET)
257 self.compute_client.CreateInstance.assert_called_with(
258 instance=self.INSTANCE,
259 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
260 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
261 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
262 build_target=self.BUILD_TARGET,
263 branch=self.BRANCH,
264 build_id=self.BUILD_ID,
265 emulator_branch=self.EMULATOR_BRANCH,
266 emulator_build_id=self.EMULATOR_BUILD_ID,
267 kernel_branch=self.KERNEL_BRANCH,
268 kernel_build_id=self.KERNEL_BUILD_ID,
269 kernel_build_target=self.KERNEL_BUILD_TARGET,
270 gpu=self.GPU,
272 extra_scopes=self.EXTRA_SCOPES,
274 launch_args=self.LAUNCH_ARGS)
276 self.assertEqual(report.data, {
278 "instance_name": self.INSTANCE,
279 "ip": self.IP.external,
280 "branch": self.BRANCH,
281 "build_id": self.BUILD_ID,
282 "build_target": self.BUILD_TARGET,
283 "emulator_branch": self.EMULATOR_BRANCH,
284 "emulator_build_id": self.EMULATOR_BUILD_ID,
285 "emulator_build_target": self.EMULATOR_BUILD_TARGET,
286 "kernel_branch": self.KERNEL_BRANCH,
287 "kernel_build_id": self.KERNEL_BUILD_ID,
288 "kernel_build_target": self.KERNEL_BUILD_TARGET,
291 self.assertEqual(report.command, "create_gf")
292 self.assertEqual(report.status, "SUCCESS")
295 self.build_client.GetBranch.side_effect = [
296 self.BRANCH, self.EMULATOR_BRANCH
300 self.build_client.GetBuildInfo.side_effect = [
302 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
304 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
305 self.EMULATOR_BUILD_TARGET, None),
307 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
308 self.KERNEL_BUILD_TARGET, None)]
310 report = create_goldfish_action.CreateDevices(avd_spec=self.avd_spec)
312 self.compute_client.CreateInstance.assert_called_with(
313 instance=self.INSTANCE,
314 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
315 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
316 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
317 build_target=self.BUILD_TARGET,
318 branch=self.BRANCH,
319 build_id=self.BUILD_ID,
320 emulator_branch=self.EMULATOR_BRANCH,
321 emulator_build_id=self.EMULATOR_BUILD_ID,
322 kernel_branch=self.KERNEL_BRANCH,
323 kernel_build_id=self.KERNEL_BUILD_ID,
324 kernel_build_target=self.KERNEL_BUILD_TARGET,
325 gpu=self.GPU,
326 avd_spec=self.avd_spec,
327 extra_scopes=self.EXTRA_SCOPES,
329 launch_args=self.LAUNCH_ARGS)
332 def testCreateDevicesWithoutEmulatorBuildId(self): argument
334 cfg = self._CreateCfg()
338 self.Patch(uuid, "uuid4", return_value=fake_uuid)
341 self.compute_client.GetInstanceIP.return_value = self.IP
342 self.compute_client.GenerateImageName.return_value = self.IMAGE
343 self.compute_client.GenerateInstanceName.return_value = self.INSTANCE
346 self.build_client.GetBuildInfo.side_effect = [
348 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
350 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
351 self.EMULATOR_BUILD_TARGET, None),
353 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
354 self.KERNEL_BUILD_TARGET, None)]
357 self.Patch(
360 return_value=self.EMULATOR_BUILD_ID)
365 none_avd_spec, cfg, build_target=self.BUILD_TARGET,
366 build_id=self.BUILD_ID, emulator_build_id=None,
367 gpu=self.GPU)
370 self.compute_client.CreateInstance.assert_called_with(
371 instance=self.INSTANCE,
372 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
373 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
374 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
375 build_target=self.BUILD_TARGET,
376 branch=self.BRANCH,
377 build_id=self.BUILD_ID,
378 emulator_branch=self.EMULATOR_BRANCH,
379 emulator_build_id=self.EMULATOR_BUILD_ID,
380 kernel_branch=self.KERNEL_BRANCH,
381 kernel_build_id=self.KERNEL_BUILD_ID,
382 kernel_build_target=self.KERNEL_BUILD_TARGET,
383 gpu=self.GPU,
385 extra_scopes=self.EXTRA_SCOPES,
387 launch_args=self.LAUNCH_ARGS)
389 self.assertEqual(report.data, {
391 "instance_name": self.INSTANCE,
392 "ip": self.IP.external,
393 "branch": self.BRANCH,
394 "build_id": self.BUILD_ID,
395 "build_target": self.BUILD_TARGET,
396 "emulator_branch": self.EMULATOR_BRANCH,
397 "emulator_build_id": self.EMULATOR_BUILD_ID,
398 "emulator_build_target": self.EMULATOR_BUILD_TARGET,
399 "kernel_branch": self.KERNEL_BRANCH,
400 "kernel_build_id": self.KERNEL_BUILD_ID,
401 "kernel_build_target": self.KERNEL_BUILD_TARGET,
404 self.assertEqual(report.command, "create_gf")
405 self.assertEqual(report.status, "SUCCESS")
408 self.build_client.GetBranch.side_effect = [
409 self.BRANCH, self.EMULATOR_BRANCH
413 self.build_client.GetBuildInfo.side_effect = [
415 self.BRANCH, self.BUILD_ID, self.BUILD_TARGET, None),
417 self.EMULATOR_BRANCH, self.EMULATOR_BUILD_ID,
418 self.EMULATOR_BUILD_TARGET, None),
420 self.KERNEL_BRANCH, self.KERNEL_BUILD_ID,
421 self.KERNEL_BUILD_TARGET, None)]
423 report = create_goldfish_action.CreateDevices(avd_spec=self.avd_spec)
425 self.compute_client.CreateInstance.assert_called_with(
426 instance=self.INSTANCE,
427 blank_data_disk_size_gb=self.EXTRA_DATA_DISK_GB,
428 image_name=self.GOLDFISH_HOST_IMAGE_NAME,
429 image_project=self.GOLDFISH_HOST_IMAGE_PROJECT,
430 build_target=self.BUILD_TARGET,
431 branch=self.BRANCH,
432 build_id=self.BUILD_ID,
433 emulator_branch=self.EMULATOR_BRANCH,
434 emulator_build_id=self.EMULATOR_BUILD_ID,
435 kernel_branch=self.KERNEL_BRANCH,
436 kernel_build_id=self.KERNEL_BUILD_ID,
437 kernel_build_target=self.KERNEL_BUILD_TARGET,
438 gpu=self.GPU,
439 avd_spec=self.avd_spec,
440 extra_scopes=self.EXTRA_SCOPES,
442 launch_args=self.LAUNCH_ARGS)