Ejemplo n.º 1
0
def test_simctl_output_parse_error(command):
    """If parsing simctl JSON output fails, an exception is raised."""
    command.subprocess.check_output.return_value = "this is not JSON"

    with pytest.raises(BriefcaseCommandError,
                       match="Unable to parse output of xcrun simctl"):
        get_device_state(command, "2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D")
Ejemplo n.º 2
0
def test_unknown_device():
    "If you ask for an invalid device UDID, an exception is raised."
    sub = mock.MagicMock()
    sub.check_output.return_value = simctl_result('no-devices')

    with pytest.raises(BriefcaseCommandError):
        get_device_state('dead-beef-dead-beef', sub=sub)
Ejemplo n.º 3
0
def test_simctl_missing(command):
    """If simctl is missing or fails to start, an exception is raised."""
    command.subprocess.check_output.side_effect = subprocess.CalledProcessError(
        cmd=["xcrun", "simctl", "list", "-j"], returncode=1)

    with pytest.raises(BriefcaseCommandError,
                       match="Unable to run xcrun simctl."):
        get_device_state(command, "2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D")
Ejemplo n.º 4
0
def test_simctl_missing():
    "If simctl is missing or fails to start, an exception is raised."
    sub = mock.MagicMock()
    sub.check_output.side_effect = subprocess.CalledProcessError(
        cmd=['xcrun', 'simctl', 'list', '-j'], returncode=1)

    with pytest.raises(BriefcaseCommandError):
        get_device_state('2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D', sub=sub)
Ejemplo n.º 5
0
def test_known_device_unknown_status(command):
    """If simctl returns something unexpected as status, we can recover."""
    command.subprocess.check_output.return_value = simctl_result(
        "single-device-unknown")

    state = get_device_state(command, "2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D")

    assert state == DeviceState.UNKNOWN
Ejemplo n.º 6
0
def test_known_device_shutting_down(command):
    """A valid device that is shutting down can be inspected."""
    command.subprocess.check_output.return_value = simctl_result(
        "single-device-shutting-down")

    state = get_device_state(command, "2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D")

    assert state == DeviceState.SHUTTING_DOWN
Ejemplo n.º 7
0
def test_known_device_booted(command):
    """A valid, booted device can be inspected."""
    command.subprocess.check_output.return_value = simctl_result(
        "single-device-booted")

    state = get_device_state(command, "2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D")

    assert state == DeviceState.BOOTED
Ejemplo n.º 8
0
def test_known_device_unknown_status():
    "If simctl returns something unexpected as status, we can recover"
    sub = mock.MagicMock()
    sub.check_output.return_value = simctl_result('single-device-unknown')

    state = get_device_state('2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D', sub=sub)

    assert state == DeviceState.UNKNOWN
Ejemplo n.º 9
0
def test_known_device_shutdown():
    "A valid, shut down device can be inspected"
    sub = mock.MagicMock()
    sub.check_output.return_value = simctl_result('single-device-shutdown')

    state = get_device_state('2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D', sub=sub)

    assert state == DeviceState.SHUTDOWN
Ejemplo n.º 10
0
def test_known_device_shutting_down():
    "A valid device that is shutting down can be inspected"
    command = mock.MagicMock()
    command.subprocess.check_output.return_value = simctl_result(
        'single-device-shutting-down')

    state = get_device_state(command, '2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D')

    assert state == DeviceState.SHUTTING_DOWN
Ejemplo n.º 11
0
def test_known_device_booted():
    "A valid, booted device can be inspected"
    command = mock.MagicMock()
    command.subprocess.check_output.return_value = simctl_result(
        'single-device-booted')

    state = get_device_state(command, '2D3503A3-6EB9-4B37-9B17-C7EFEF2FA32D')

    assert state == DeviceState.BOOTED
Ejemplo n.º 12
0
def test_unknown_device(command):
    """If you ask for an invalid device UDID, an exception is raised."""
    command.subprocess.check_output.return_value = simctl_result("no-devices")

    with pytest.raises(BriefcaseCommandError):
        get_device_state(command, "dead-beef-dead-beef")