File: test_list_packages.py

package info (click to toggle)
python-briefcase 0.3.22-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,300 kB
  • sloc: python: 59,405; makefile: 57
file content (29 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import subprocess

import pytest

from briefcase.exceptions import BriefcaseCommandError


def test_list_packages(mock_tools, android_sdk):
    """Sdkmanager can be used to list the packages managed by the Android SDK."""
    android_sdk.list_packages()

    mock_tools.subprocess.check_output.assert_called_once_with(
        [android_sdk.sdkmanager_path, "--list_installed"],
        env=android_sdk.env,
    )


def test_list_packages_failure(mock_tools, android_sdk):
    """If sdkmanager fails, an error is raised."""
    mock_tools.subprocess.check_output.side_effect = subprocess.CalledProcessError(
        1, ""
    )
    with pytest.raises(BriefcaseCommandError):
        android_sdk.list_packages()

    mock_tools.subprocess.check_output.assert_called_once_with(
        [android_sdk.sdkmanager_path, "--list_installed"],
        env=android_sdk.env,
    )