diff --git a/core/utils/device/simctl.py b/core/utils/device/simctl.py index 336a739c..a30d8116 100644 --- a/core/utils/device/simctl.py +++ b/core/utils/device/simctl.py @@ -40,7 +40,7 @@ def is_running(simulator_info): for sim in sims: if sim['name'] == simulator_info.name and sim['state'] == 'Booted': # simctl returns Booted too early, so we will wait some untill service is started - simulator_info.id = sim['udid'] + simulator_info.id = str(sim['udid']) command = 'spawn {0} launchctl print system | grep com.apple.springboard.services'.format( simulator_info.id) service_state = Simctl.__run_simctl_command(command=command) @@ -72,7 +72,7 @@ def is_available(simulator_info): sims = Simctl.__get_simulators()['devices']['iOS {0}'.format(simulator_info.sdk)] for sim in sims: if sim['name'] == simulator_info.name: - simulator_info.id = sim['udid'] + simulator_info.id = str(sim['udid']) return simulator_info return False diff --git a/tests/cli/run/device/device.py b/tests/cli/run/device/device.py new file mode 100644 index 00000000..09b8cbd7 --- /dev/null +++ b/tests/cli/run/device/device.py @@ -0,0 +1,35 @@ +""" +Tests for `tns devices` command +""" +import os +import unittest + +from core.base_test.tns_run_test import TnsRunTest +from core.enums.os_type import OSType +from core.settings import Settings +from products.nativescript.tns import Tns + + +# noinspection PyMethodMayBeStatic +class TnsDeviceTests(TnsRunTest): + PATH = os.environ.get('PATH') + ANDROID_HOME = os.environ.get('ANDROID_HOME') + + def setUp(self): + TnsRunTest.setUp(self) + os.environ['PATH'] = self.PATH + os.environ['ANDROID_HOME'] = self.ANDROID_HOME + + @unittest.skipIf(Settings.HOST_OS == OSType.WINDOWS, 'Skip on Windows machines.') + def test_400_list_devices_without_android_sdk(self): + path_without_android = '' + for path in self.PATH.split(':'): + if self.ANDROID_HOME not in path: + path_without_android = path_without_android + path + ':' + os.environ['PATH'] = path_without_android + os.environ['ANDROID_HOME'] = 'WRONG_PATH' + result = Tns.exec_command(command='devices') + assert self.emu.name in result.output + assert self.emu.id in result.output + assert self.sim.name in result.output + assert self.sim.id in result.output