diff options
Diffstat (limited to 'tests/plugin_tests')
-rw-r--r-- | tests/plugin_tests/conftest.py | 20 | ||||
-rw-r--r-- | tests/plugin_tests/gnome_test.py | 45 | ||||
-rw-r--r-- | tests/plugin_tests/numpy3_test.data | 4 | ||||
-rw-r--r-- | tests/plugin_tests/numpy3_test.py | 38 | ||||
-rw-r--r-- | tests/plugin_tests/perl-openssl_test.py | 33 | ||||
-rwxr-xr-x | tests/plugin_tests/perl-ssl_test.sh | 5 |
6 files changed, 145 insertions, 0 deletions
diff --git a/tests/plugin_tests/conftest.py b/tests/plugin_tests/conftest.py new file mode 100644 index 0000000..f2a8aea --- /dev/null +++ b/tests/plugin_tests/conftest.py @@ -0,0 +1,20 @@ +import os + +import pytest + + +@pytest.fixture(autouse=True) +def workaround_debputys_own_test_suite() -> None: + # This fixture is only required as long as the tests are run inside `debputy`'s + # own test suite. If you copy out a plugin + tests, you should *not* need this + # fixture. + # + # The problem appears because in the debputy source package, these plugins are + # always provided in their "installed" location. + orig = os.environ.get("DEBPUTY_TEST_PLUGIN_LOCATION") + os.environ["DEBPUTY_TEST_PLUGIN_LOCATION"] = "installed" + yield + if orig is None: + del os.environ["DEBPUTY_TEST_PLUGIN_LOCATION"] + else: + os.environ["DEBPUTY_TEST_PLUGIN_LOCATION"] = orig diff --git a/tests/plugin_tests/gnome_test.py b/tests/plugin_tests/gnome_test.py new file mode 100644 index 0000000..ec27a85 --- /dev/null +++ b/tests/plugin_tests/gnome_test.py @@ -0,0 +1,45 @@ +import pytest + +from debputy.plugin.api.test_api import ( + initialize_plugin_under_test, + build_virtual_file_system, + package_metadata_context, +) + + +@pytest.mark.parametrize( + "version,expected_version,expected_next_version", + [ + ( + "1:3.36.1", + "1:3.36", + "1:3.38", + ), + ( + "3.38.2", + "3.38", + "40", + ), + ( + "40.2.0", + "40~", + "41~", + ), + ( + "40", + "40~", + "41~", + ), + ], +) +def test_gnome_plugin( + version: str, + expected_version: str, + expected_next_version: str, +) -> None: + plugin = initialize_plugin_under_test() + fs = build_virtual_file_system([]) + context = package_metadata_context(binary_package_version=version) + metadata = plugin.run_metadata_detector("gnome-versions", fs, context) + assert metadata.substvars["gnome:Version"] == expected_version + assert metadata.substvars["gnome:NextVersion"] == expected_next_version diff --git a/tests/plugin_tests/numpy3_test.data b/tests/plugin_tests/numpy3_test.data new file mode 100644 index 0000000..22b65a2 --- /dev/null +++ b/tests/plugin_tests/numpy3_test.data @@ -0,0 +1,4 @@ +# Values taken from 1:1.24.2-1 +abi 9 +api 16 +api-min-version 1:1.22.0 diff --git a/tests/plugin_tests/numpy3_test.py b/tests/plugin_tests/numpy3_test.py new file mode 100644 index 0000000..9b252fb --- /dev/null +++ b/tests/plugin_tests/numpy3_test.py @@ -0,0 +1,38 @@ +import os + +import pytest + +from debputy.plugin.api.test_api import ( + initialize_plugin_under_test, + build_virtual_file_system, + package_metadata_context, +) + +DATA_FILE = os.path.join(os.path.dirname(__file__), "numpy3_test.data") + + +@pytest.fixture(scope="session") +def numpy3_stub_data_file() -> None: + os.environ["_NUMPY_TEST_PATH"] = DATA_FILE + yield + try: + del os.environ["_NUMPY_TEST_PATH"] + except KeyError: + pass + + +def test_numpy3_plugin_arch_all(numpy3_stub_data_file) -> None: + plugin = initialize_plugin_under_test() + fs = build_virtual_file_system([]) + context = package_metadata_context(package_fields={"Architecture": "all"}) + metadata = plugin.run_metadata_detector("numpy-depends", fs, context) + assert metadata.substvars["python3:Depends"] == "python3-numpy" + + +def test_numpy3_plugin_arch_any(numpy3_stub_data_file) -> None: + plugin = initialize_plugin_under_test() + fs = build_virtual_file_system([]) + context = package_metadata_context(package_fields={"Architecture": "any"}) + metadata = plugin.run_metadata_detector("numpy-depends", fs, context) + expected = "python3-numpy (>= 1:1.22.0), python3-numpy-abi9" + assert metadata.substvars["python3:Depends"] == expected diff --git a/tests/plugin_tests/perl-openssl_test.py b/tests/plugin_tests/perl-openssl_test.py new file mode 100644 index 0000000..37f2ba1 --- /dev/null +++ b/tests/plugin_tests/perl-openssl_test.py @@ -0,0 +1,33 @@ +import stat +import os + +import pytest + +from debputy.plugin.api.test_api import ( + initialize_plugin_under_test, + build_virtual_file_system, + package_metadata_context, +) + +STUB_CMD = os.path.join(os.path.dirname(__file__), "perl-ssl_test.sh") + + +@pytest.fixture(scope="session") +def perl_ssl_stub_cmd() -> None: + os.environ["_PERL_SSL_DEFAULTS_TEST_PATH"] = STUB_CMD + mode = stat.S_IMODE(os.stat(STUB_CMD).st_mode) + if (mode & 0o500) != 0o500: + os.chmod(STUB_CMD, mode | 0o500) + yield + try: + del os.environ["_PERL_SSL_DEFAULTS_TEST_PATH"] + except KeyError: + pass + + +def test_perl_openssl(perl_ssl_stub_cmd) -> None: + plugin = initialize_plugin_under_test() + fs = build_virtual_file_system([]) + context = package_metadata_context(package_fields={"Architecture": "all"}) + metadata = plugin.run_metadata_detector("perl-openssl-abi", fs, context) + assert metadata.substvars["perl:Depends"] == "perl-openssl-abi-3" diff --git a/tests/plugin_tests/perl-ssl_test.sh b/tests/plugin_tests/perl-ssl_test.sh new file mode 100755 index 0000000..5238dc7 --- /dev/null +++ b/tests/plugin_tests/perl-ssl_test.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# The original script looks up libssl.so and extract part of the SONAME, +# which is all adequately stubbed by: +echo 3 |