diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-05-03 19:46:49 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-05-04 20:16:38 +0900 |
commit | 3f90c2f944bc1cd1ea9dbd63a445d150e4a92e33 (patch) | |
tree | bed29ca321d305286c875a883aa6dd635dd99811 | |
parent | 17259656bc2d9bbd001fa19170bb1f751ca272d1 (diff) | |
download | buildstream-3f90c2f944bc1cd1ea9dbd63a445d150e4a92e33.tar.gz |
tests/plugins/loading.py: Test failure modes when loading pip plugins
-rw-r--r-- | tests/plugins/loading.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py index 1c5dc4546..13d787b0e 100644 --- a/tests/plugins/loading.py +++ b/tests/plugins/loading.py @@ -349,3 +349,82 @@ def test_pip_origin_load_success(cli, datafiles, plugin_type): result = cli.run(project=project, args=["show", "element.bst"]) result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON) +def test_pip_origin_with_constraints(cli, datafiles, plugin_type): + project = str(datafiles) + + update_project( + project, + { + "plugins": [ + {"origin": "pip", "package-name": "sample-plugins>=1.0,<1.2.5,!=1.1.3", plugin_type: ["sample"],} + ] + }, + ) + setup_element(project, plugin_type, "sample") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +def test_pip_origin_package_not_found(cli, datafiles, plugin_type): + project = str(datafiles) + + update_project( + project, {"plugins": [{"origin": "pip", "package-name": "not-a-package", plugin_type: ["sample"],}]}, + ) + setup_element(project, plugin_type, "sample") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.PLUGIN, "package-not-found") + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON) +def test_pip_origin_plugin_not_found(cli, datafiles, plugin_type): + project = str(datafiles) + + update_project( + project, {"plugins": [{"origin": "pip", "package-name": "sample-plugins", plugin_type: ["notfound"],}]}, + ) + setup_element(project, plugin_type, "notfound") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.PLUGIN, "plugin-not-found") + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON) +def test_pip_origin_version_conflict(cli, datafiles, plugin_type): + project = str(datafiles) + + update_project( + project, {"plugins": [{"origin": "pip", "package-name": "sample-plugins>=1.4", plugin_type: ["sample"],}]}, + ) + setup_element(project, plugin_type, "sample") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.PLUGIN, "package-version-conflict") + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON) +def test_pip_origin_malformed_constraints(cli, datafiles, plugin_type): + project = str(datafiles) + + update_project( + project, {"plugins": [{"origin": "pip", "package-name": "sample-plugins>1.4,A", plugin_type: ["sample"],}]}, + ) + setup_element(project, plugin_type, "sample") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.PLUGIN, "package-malformed-requirement") |