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 19:35:43 +0900 |
commit | 659d351ca9ab7bda722ef32084e88c2a502227e6 (patch) | |
tree | 549b6f8d65b9c44289fac0e608e29223a04c39e0 | |
parent | 5db3ffc2032c1e628194124e334e44962666dafb (diff) | |
download | buildstream-659d351ca9ab7bda722ef32084e88c2a502227e6.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 7a57b4a5a..30f9009ae 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") |