Files
aqtinstall/tests/test_metadata.py
Alexandre Poumaroux a09b5cee28 Fix WASM (#846)
* Rewrite WASM support

* Add WASM tests to CI, update CI to test more the latest versions, add auto EMSDK version detection function

* Fix some mistakes, typos, moved emsdk version function into BuildJob

* Fix issue related to extensions interfering with wasm on 6.8+

* Fix tests

* Remove dep on Version in CI

* Remove safety before patch

* handle cases where extensions don't exist.

for example with windows desktop 6.8.1 win64_msvc2022_arm64_cross_compiled
both qtwebengine and qtpdf don't exist.

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* for --long-modules assume extension doesn't exist on download error.

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* for --modules assume extension doesn't exist for download failures.

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* reformat with black

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* fix flake8 regression that doesn't occur locally.

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* Fix autodesktop by also updating the OS when searching for a valid desktop version to download

* Fix extension issue, reduce the possible retry for getting extensions to prevent server spam

* Fix CI asking for msvc2019 on 6.8+ but its no longer supported

* Make CI use C++20 and MSVC2022

* Fix linux build

* Update runners to windows-2022

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* Fix patching

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* Add back the semantic version changes to prevent crashes, add tests for it

* Update checks

* Cast 'https://mirrors.ustc.edu.cn' to the shadow realm

* Again

* Update settings.ini

* Update settings.ini

* Update settings.ini

* Remove one_rep on silent

* Update settings.ini

* Restore master settings, remove hash check

* ci: Use specific mirror

Attempt to work around download errors in Azure due to Qt's official download site often redirecting to mirrors to which the network connection is unstable

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* Re enable hash checking

* Treat read timeout error during download as connection error

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>

* Add test for modules in WASM with autodesktop

* Fix format

* Fix test

* Make '--autodesktop' trigger its own install process, and test it

* Fix older autodesktop tests

* Add mock update files for 680 wasm, add test for wasm 680 autodesktop

* Passes the additional tests

* Fix format

* Improve coverage, fix format

* Fix tests and improve logging or install

* Fix format

* Fix regression in other tests

* Use flavor

* Fix line len

* Fix codeql

* Fix list-qt for WASM arch on 6.5.x and 6.6.x, restore to original download URL

* Fix test error

* Revert ci settings URL as it is never used by clients, only in CI

* Add comment for clarity in ci/settings.ini

---------

Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>
Co-authored-by: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Co-authored-by: J.D. Purcell <jdpurcell@gmail.com>
2025-01-06 15:35:40 +09:00

60 lines
2.0 KiB
Python

import pytest
from aqt.metadata import Version, get_semantic_version
@pytest.mark.parametrize(
"input_version, is_preview, expected",
[
# Test cases for non-preview versions
("51212", False, Version("5.12.12")),
("600", False, Version("6.0.0")),
("6_7_3", False, Version("6.7.3")),
("6_7", False, Version("6.7.0")),
# Test cases for preview versions
("51212", True, Version("5.1212-preview")),
("600", True, Version("6.0-preview")),
("6_7_3", True, Version("6.73-preview")),
("6_7", True, Version("6.7-preview")),
],
)
def test_get_semantic_version_valid(input_version, is_preview, expected):
"""
Test the get_semantic_version function with valid inputs.
Args:
input_version (str): Input version string to be converted
is_preview (bool): Flag indicating whether this is a preview version
expected (Version): Expected semantic version output
"""
result = get_semantic_version(input_version, is_preview)
assert (
result == expected
), f"Failed for input '{input_version}' with is_preview={is_preview}. Expected '{expected}', but got '{result}'"
@pytest.mark.parametrize(
"invalid_input, is_preview",
[
("", False), # Empty string
("abc", False), # Non-numeric input
("1_2_3_4", False), # Too many underscores
("1_a_2", False), # Non-numeric parts
(None, False), # None input
],
)
def test_get_semantic_version_returns_none(invalid_input, is_preview):
"""
Test cases where the function should return None.
"""
result = get_semantic_version(invalid_input, is_preview)
assert result is None, f"Expected None for invalid input '{invalid_input}', but got '{result}'"
def test_get_semantic_version_raises_value_error():
"""
Test the specific case that raises ValueError - single digit version.
"""
with pytest.raises(ValueError, match="Invalid version string '1'"):
get_semantic_version("1", False)