Skip to content

Commit

Permalink
Move auth test to test_commercial to not have a qtaccount.ini generated
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidev committed Jan 29, 2025
1 parent 3ad9869 commit 7793c1b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
33 changes: 0 additions & 33 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import platform
import re
import sys
from pathlib import Path
Expand Down Expand Up @@ -521,35 +520,3 @@ def test_get_autodesktop_dir_and_arch_non_android(
), "Expected autodesktop install message."
elif expect["instruct"]:
assert any("You can install" in line for line in err_lines), "Expected install instruction message."


@pytest.mark.enable_socket
@pytest.mark.parametrize(
"cmd, expected_arch, expected_err",
[
pytest.param(
"install-qt-commercial desktop {} 6.8.0",
{"windows": "win64_msvc2022_64", "linux": "linux_gcc_64", "mac": "clang_64"},
"No Qt account credentials found",
),
],
)
def test_cli_login_qt_commercial(capsys, monkeypatch, cmd, expected_arch, expected_err):
"""Test commercial Qt installation command"""
# Detect current platform
current_platform = platform.system().lower()
arch = expected_arch[current_platform]
cmd = cmd.format(arch)

def mock_config_file(*args, **kwargs):
return "real_config.ini"

monkeypatch.setattr("aqt.helper.get_qt_account_path", mock_config_file)

cli = Cli()
cli._setup_settings()
result = cli.run(cmd.split())

_, err = capsys.readouterr()
assert str(err).find(expected_err) >= 0
assert result != 0
32 changes: 32 additions & 0 deletions tests/test_commercial.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ def commercial_installer():
)


@pytest.mark.enable_socket
@pytest.mark.parametrize(
"cmd, expected_arch, expected_err",
[
pytest.param(
"install-qt-commercial desktop {} 6.8.0",
{"windows": "win64_msvc2022_64", "linux": "linux_gcc_64", "mac": "clang_64"},
"No Qt account credentials found",
),
],
)
def test_cli_login_qt_commercial(capsys, monkeypatch, cmd, expected_arch, expected_err):
"""Test commercial Qt installation command"""
# Detect current platform
current_platform = sys.platform.lower()
arch = expected_arch[current_platform]
cmd = cmd.format(arch)

def mock_config_file(*args, **kwargs):
return "real_config.ini"

monkeypatch.setattr("aqt.helper.get_qt_account_path", mock_config_file)

cli = Cli()
cli._setup_settings()
result = cli.run(cmd.split())

_, err = capsys.readouterr()
assert str(err).find(expected_err) >= 0
assert result != 0


def test_package_manager_init():
"""Test QtPackageManager initialization"""
manager = QtPackageManager(
Expand Down

0 comments on commit 7793c1b

Please sign in to comment.