From 5547a87f0b708cec8a13d5b42d726cfa97ca0f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 20 Jan 2022 12:24:10 +0100 Subject: [PATCH] Add eval tests to RHEL %py_provides Obsoletes functionality --- tests/test_evals.py | 67 +++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/tests/test_evals.py b/tests/test_evals.py index ae2b606..2027a01 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -168,67 +168,92 @@ def test_python_provide_doubleuse(): assert len(set(lines)) == 3 -def test_py_provides_python(): - lines = rpm_eval('%py_provides python-foo', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 10]) +def test_py_provides_python(rhel): + lines = rpm_eval('%py_provides python-foo', version='6', release='1.fc66', rhel=rhel) assert 'Provides: python-foo = 6-1.fc66' in lines assert len(lines) == 1 -def test_py_provides_whatever(): - lines = rpm_eval('%py_provides whatever', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 12]) +def test_py_provides_whatever(rhel): + lines = rpm_eval('%py_provides whatever', version='6', release='1.fc66', rhel=rhel) assert 'Provides: whatever = 6-1.fc66' in lines assert len(lines) == 1 -def test_py_provides_python3(): - lines = rpm_eval('%py_provides python3-foo', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 9]) +def test_py_provides_python3(rhel): + lines = rpm_eval('%py_provides python3-foo', version='6', release='1.fc66', rhel=rhel) assert 'Provides: python3-foo = 6-1.fc66' in lines assert 'Provides: python-foo = 6-1.fc66' in lines assert f'Provides: python{X_Y}-foo = 6-1.fc66' in lines - assert len(lines) == 3 + if rhel: + assert f'Obsoletes: python{X_Y}-foo < 6-1.fc66' in lines + assert len(lines) == 4 + else: + assert len(lines) == 3 -def test_py_provides_python3_epoched(): - lines = rpm_eval('%py_provides python3-foo', epoch='1', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 13]) +def test_py_provides_python3_epoched(rhel): + lines = rpm_eval('%py_provides python3-foo', epoch='1', version='6', release='1.fc66', rhel=rhel) assert 'Provides: python3-foo = 1:6-1.fc66' in lines assert 'Provides: python-foo = 1:6-1.fc66' in lines assert f'Provides: python{X_Y}-foo = 1:6-1.fc66' in lines - assert len(lines) == 3 + if rhel: + assert f'Obsoletes: python{X_Y}-foo < 1:6-1.fc66' in lines + assert len(lines) == 4 + else: + assert len(lines) == 3 -def test_py_provides_python3X(): - lines = rpm_eval(f'%py_provides python{X_Y}-foo', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 13]) +def test_py_provides_python3X(rhel): + lines = rpm_eval(f'%py_provides python{X_Y}-foo', version='6', release='1.fc66', rhel=rhel) assert f'Provides: python{X_Y}-foo = 6-1.fc66' in lines assert 'Provides: python-foo = 6-1.fc66' in lines assert 'Provides: python3-foo = 6-1.fc66' in lines assert len(lines) == 3 -def test_py_provides_python3X_epoched(): - lines = rpm_eval(f'%py_provides python{X_Y}-foo', epoch='1', version='6', release='1.fc66') +@pytest.mark.parametrize('rhel', [None, 27]) +def test_py_provides_python3X_epoched(rhel): + lines = rpm_eval(f'%py_provides python{X_Y}-foo', epoch='1', version='6', release='1.fc66', rhel=rhel) assert f'Provides: python{X_Y}-foo = 1:6-1.fc66' in lines assert 'Provides: python-foo = 1:6-1.fc66' in lines assert 'Provides: python3-foo = 1:6-1.fc66' in lines assert len(lines) == 3 -def test_py_provides_doubleuse(): +@pytest.mark.parametrize('rhel', [None, 2]) +def test_py_provides_doubleuse(rhel): lines = rpm_eval('%{py_provides python3-foo}%{py_provides python3-foo}', - version='6', release='1.fc66') + version='6', release='1.fc66', rhel=rhel) assert 'Provides: python3-foo = 6-1.fc66' in lines assert 'Provides: python-foo = 6-1.fc66' in lines assert f'Provides: python{X_Y}-foo = 6-1.fc66' in lines - assert len(lines) == 6 - assert len(set(lines)) == 3 + if rhel: + assert f'Obsoletes: python{X_Y}-foo < 6-1.fc66' in lines + assert len(lines) == 8 + assert len(set(lines)) == 4 + else: + assert len(lines) == 6 + assert len(set(lines)) == 3 -def test_py_provides_with_evr(): +@pytest.mark.parametrize('rhel', [None, 2]) +def test_py_provides_with_evr(rhel): lines = rpm_eval('%py_provides python3-foo 123', - version='6', release='1.fc66') + version='6', release='1.fc66', rhel=rhel) assert 'Provides: python3-foo = 123' in lines assert 'Provides: python-foo = 123' in lines assert f'Provides: python{X_Y}-foo = 123' in lines - assert len(lines) == 3 + if rhel: + assert f'Obsoletes: python{X_Y}-foo < 123' in lines + assert len(lines) == 4 + else: + assert len(lines) == 3 def test_python_wheel_pkg_prefix():