Beispiel #1
0
 async def clone(
         self,
         udid: str,
         destination_device_set: Optional[str] = None) -> TargetDescription:
     arguments = ["--clone", udid]
     if destination_device_set is not None:
         arguments.extend(
             ["--clone-destination-set", destination_device_set])
     output = await self._run_companion_command(arguments=arguments)
     return target_description_from_json(output.splitlines()[-1])
Beispiel #2
0
 async def list_targets(
         self,
         only: Optional[OnlyFilter] = None,
         timeout: Optional[timedelta] = None) -> List[TargetDescription]:
     arguments = ["--list", "1"] + _only_arg_from_filter(only=only)
     output = await self._run_companion_command(arguments=arguments,
                                                timeout=timeout)
     return [
         target_description_from_json(data=line.strip())
         for line in output.splitlines() if len(line.strip())
     ]
Beispiel #3
0
 async def list_targets(
         self,
         only: Optional[TargetType] = None) -> List[TargetDescription]:
     arguments = ["--list", "1"]
     if only is not None:
         arguments.extend([
             "--only",
             "simulator" if only is TargetType.SIMULATOR else "device"
         ])
     output = await self._run_companion_command(arguments=arguments)
     return [
         target_description_from_json(data=line.strip())
         for line in output.splitlines() if len(line.strip())
     ]
Beispiel #4
0
 async def boot_headless(self,
                         udid: str,
                         verify: bool = True) -> AsyncGenerator[None, None]:
     async with self._start_companion_command([
             "--headless",
             "1",
             "--boot",
             udid,
             "--verify-booted",
             "1" if verify else "0",
     ]) as process:
         # The first line written to stdout is information about the booted sim.
         line = (await none_throws(process.stdout).readline()).decode()
         target = target_description_from_json(line)
         self._logger.info(f"{target} is now booted")
         yield None
         self._logger.info(f"Done with {target}. Shutting down.")
Beispiel #5
0
 async def boot_headless(
         self,
         udid: str,
         verify: bool = True,
         timeout: Optional[timedelta] = None) -> AsyncGenerator[None, None]:
     async with self._start_companion_command([
             "--headless",
             "1",
             "--boot",
             udid,
             "--verify-booted",
             "1" if verify else "0",
     ]) as process:
         # The first line written to stdout is information about the booted sim.
         data = await asyncio.wait_for(
             none_throws(process.stdout).readline(),
             timeout=None if timeout is None else timeout.total_seconds(),
         )
         line = data.decode()
         target = target_description_from_json(line)
         self._logger.info(f"{target} is now booted")
         yield None
         self._logger.info(f"Done with {target}. Shutting down.")
Beispiel #6
0
 def test_target_description_all_optional_fields(self) -> None:
     target = TARGET_DESCRIPTION_FIXTURE._replace(
         companion_info=COMPANION_INFO_FIXTURE)
     self.assertEqual(
         target,
         target_description_from_json(json_format_target_info(target)))
Beispiel #7
0
 def test_target_description_no_optional_fields(self) -> None:
     self.assertEqual(
         TARGET_DESCRIPTION_FIXTURE,
         target_description_from_json(
             json_format_target_info(TARGET_DESCRIPTION_FIXTURE)),
     )
Beispiel #8
0
 async def create(self, device_type: str, os_version: str) -> TargetDescription:
     output = await self._run_companion_command(
         arguments=["--create", f"{device_type},{os_version}"]
     )
     return target_description_from_json(output.splitlines()[-1])
Beispiel #9
0
 async def clone(self, udid: str) -> str:
     output = await self._run_udid_command(udid=udid, command="clone")
     cloned = target_description_from_json(output.splitlines()[-1])
     return cloned.udid