Add tests for list-src, list-doc, list-example

This commit is contained in:
David Dalcino
2021-11-17 11:18:13 -08:00
parent b929dc1f4b
commit 092d4e8c02
4 changed files with 258 additions and 3 deletions

View File

@@ -108,6 +108,13 @@ steps:
fi fi
aqt list-qt $(HOST) $(TARGET) $ext --arch $(QT_VERSION) # print architectures for version/host/target aqt list-qt $(HOST) $(TARGET) $ext --arch $(QT_VERSION) # print architectures for version/host/target
aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" --arch latest aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" --arch latest
# list-src/doc/example
aqt list-src $(HOST) $(QT_VERSION) # print source archives available for host/desktop/version
aqt list-doc $(HOST) $(QT_VERSION) # print docs archives available for host/desktop/version
aqt list-doc $(HOST) $(QT_VERSION) --modules # print docs modules available for host/desktop/version
aqt list-example $(HOST) $(QT_VERSION) # print example archives available for host/desktop/version
aqt list-example $(HOST) $(QT_VERSION) --modules # print example modules available for host/desktop/version
fi fi
if [[ "$(SUBCOMMAND)" == "install-src" ]]; then if [[ "$(SUBCOMMAND)" == "install-src" ]]; then
python -m aqt $(SUBCOMMAND) $(HOST) $(TARGET) $(QT_VERSION) --archives $(SUBARCHIVES) python -m aqt $(SUBCOMMAND) $(HOST) $(TARGET) $(QT_VERSION) --archives $(SUBARCHIVES)

View File

@@ -24,5 +24,176 @@
"examples.qtwebengine", "examples.qtwebengine",
"src" "src"
], ],
"architectures": [] "architectures": [],
"src": {
"modules": [],
"archives": [
"qtactiveqt",
"qtandroidextras",
"qtdoc",
"qtmacextras",
"qtwayland",
"qtwinextras",
"qtbase",
"qtconnectivity",
"qtx11extras",
"qtwebchannel",
"qtmultimedia",
"qttranslations",
"qtgraphicaleffects",
"qtsvg",
"qtdeclarative",
"qtwebsockets",
"qtimageformats",
"qttools",
"qtxmlpatterns",
"qtsensors",
"qtserialport",
"qtlocation",
"qtquickcontrols",
"qtquickcontrols2",
"qtremoteobjects",
"qt3d",
"qtwebview",
"qtserialbus",
"qtscxml",
"qtcharts",
"qtdatavis3d",
"qtpurchasing",
"qtvirtualkeyboard",
"qtwebengine",
"qtgamepad",
"qtscript",
"qtspeech",
"qtnetworkauth",
"qtwebglplugin",
"qtlottie",
"qtquick3d",
"qtquicktimeline",
"tqtc"
]
},
"doc": {
"modules": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebengine"
],
"archives": [
"activeqt",
"qdoc",
"qmake",
"qt3d",
"qtandroidextras",
"qtassistant",
"qtbluetooth",
"qtconcurrent",
"qtcmake",
"qtcore",
"qtdbus",
"qtdesigner",
"qtdistancefieldgenerator",
"qtdoc",
"qtgamepad",
"qtgraphicaleffects",
"qtgui",
"qthelp",
"qtimageformats",
"qtlabscalendar",
"qtlabsplatform",
"qtlinguist",
"qtlocation",
"qtmacextras",
"qtmultimedia",
"qtnetwork",
"qtnfc",
"qtopengl",
"qtplatformheaders",
"qtpositioning",
"qtprintsupport",
"qtqml",
"qtqmlmodels",
"qtqmltest",
"qtquick",
"qtquickcontrols",
"qtquickcontrols1",
"qtquickdialogs",
"qtquickextras",
"qtremoteobjects",
"qtscxml",
"qtsensors",
"qtserialbus",
"qtserialport",
"qtspeech",
"qtsql",
"qtsvg",
"qttestlib",
"qtuitools",
"qtwaylandcompositor",
"qtwebchannel",
"qtwebsockets",
"qtwebview",
"qtwidgets",
"qtwinextras",
"qtx11extras",
"qtxml",
"qtxmlpatterns",
"tqtc"
]
},
"examples": {
"modules": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebengine"
],
"archives": [
"qt3d",
"qtactiveqt",
"qtandroidextras",
"qtbase",
"qtconnectivity",
"qtdeclarative",
"qtdoc",
"qtgamepad",
"qtgraphicaleffects",
"qtimageformats",
"qtlocation",
"qtmacextras",
"qtmultimedia",
"qtquickcontrols",
"qtquickcontrols2",
"qtremoteobjects",
"qtscxml",
"qtsensors",
"qtserialbus",
"qtserialport",
"qtspeech",
"qtsvg",
"qttools",
"qttranslations",
"qtwayland",
"qtwebchannel",
"qtwebsockets",
"qtwebview",
"qtwinextras",
"qtx11extras",
"qtxmlpatterns",
"tqtc"
]
}
} }

View File

@@ -14,7 +14,7 @@ def expected_help(actual, prefix=None):
expected = ( expected = (
"usage: aqt [-h] [-c CONFIG]\n" "usage: aqt [-h] [-c CONFIG]\n"
" {install-qt,install-tool,install-doc,install-example,install-src," " {install-qt,install-tool,install-doc,install-example,install-src,"
"list-qt,list-tool," "list-qt,list-tool,list-doc,list-example,list-src,"
"install,tool,doc,examples,src,help,version}\n" "install,tool,doc,examples,src,help,version}\n"
" ...\n" " ...\n"
"\n" "\n"
@@ -35,7 +35,7 @@ def expected_help(actual, prefix=None):
"removal\n" "removal\n"
"\n" "\n"
" {install-qt,install-tool,install-doc,install-example,install-src,list-qt," " {install-qt,install-tool,install-doc,install-example,install-src,list-qt,"
"list-tool," "list-tool,list-doc,list-example,list-src,"
"install,tool,doc,examples,src,help,version}\n" "install,tool,doc,examples,src,help,version}\n"
" Please refer to each help message by using '--help' " " Please refer to each help message by using '--help' "
"with each subcommand\n", "with each subcommand\n",

View File

@@ -206,6 +206,83 @@ def test_list_architectures_and_modules(monkeypatch, version: str, extension: st
assert arches == expect["architectures"] assert arches == expect["architectures"]
@pytest.fixture
def win_5152_sde_xml_file() -> str:
return (Path(__file__).parent / "data" / "windows-5152-src-doc-example-update.xml").read_text("utf-8")
def win_5152_sde_expected(cmd_type: str, query_type: str) -> Set[str]:
assert cmd_type in ("src", "doc", "examples")
assert query_type in ("archives", "modules")
_json = json.loads((Path(__file__).parent / "data/windows-5152-src-doc-example-expect.json").read_text("utf-8"))
return set(_json[cmd_type][query_type])
@pytest.mark.parametrize(
"cmd_type, host, version, expected",
[
(
_cmd_type,
"windows",
"5.15.2",
win_5152_sde_expected(_cmd_type, "archives"),
)
for _cmd_type in ("src", "doc", "examples")
],
)
def test_list_src_doc_examples_archives(
monkeypatch, win_5152_sde_xml_file, cmd_type: str, host: str, version: str, expected: Set[str]
):
monkeypatch.setattr(MetadataFactory, "fetch_http", lambda self, _: win_5152_sde_xml_file)
archive_id = ArchiveId("qt", host, "desktop", "src_doc_examples")
archives = set(MetadataFactory(archive_id).fetch_archives_sde(cmd_type, Version(version)))
assert archives == expected
@pytest.mark.parametrize(
"cmd_type, host, version, expected",
[
(
_cmd_type,
"windows",
"5.15.2",
win_5152_sde_expected(_cmd_type, "modules"),
)
for _cmd_type in ("doc", "examples")
],
)
def test_list_src_doc_examples_modules(
monkeypatch, win_5152_sde_xml_file, cmd_type: str, host: str, version: str, expected: Set[str]
):
monkeypatch.setattr(MetadataFactory, "fetch_http", lambda self, _: win_5152_sde_xml_file)
archive_id = ArchiveId("qt", host, "desktop", "src_doc_examples")
modules = set(MetadataFactory(archive_id).fetch_modules_sde(cmd_type, Version(version)))
assert modules == expected
@pytest.mark.parametrize(
"command, expected",
(
("list-src windows 5.15.2", win_5152_sde_expected("src", "archives")),
("list-doc windows 5.15.2", win_5152_sde_expected("doc", "archives")),
("list-example windows 5.15.2", win_5152_sde_expected("examples", "archives")),
("list-doc windows 5.15.2 --modules", win_5152_sde_expected("doc", "modules")),
("list-example windows 5.15.2 --modules", win_5152_sde_expected("examples", "modules")),
),
)
def test_list_src_doc_examples_cli(monkeypatch, capsys, win_5152_sde_xml_file, command: str, expected: Set[str]):
monkeypatch.setattr(MetadataFactory, "fetch_http", lambda self, _: win_5152_sde_xml_file)
cli = Cli()
assert 0 == cli.run(command.split())
out, err = capsys.readouterr()
assert not err
out_set = set(out.strip().split())
assert out_set == expected
@pytest.mark.parametrize( @pytest.mark.parametrize(
"version, arch, modules_to_query, modules_failed_query", "version, arch, modules_to_query, modules_failed_query",
( (