|
| 1 | +import pytest |
| 2 | + |
| 3 | +from pulp_glue.common.context import PluginRequirement, PulpContext |
| 4 | +from pulp_glue.common.exceptions import PulpException |
| 5 | + |
| 6 | +pytestmark = pytest.mark.glue |
| 7 | + |
| 8 | + |
| 9 | +def test_has_plugin(mock_pulp_ctx: PulpContext) -> None: |
| 10 | + assert mock_pulp_ctx.has_plugin(PluginRequirement("core")) |
| 11 | + assert mock_pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.50")) |
| 12 | + assert not mock_pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.50,<3.60")) |
| 13 | + assert not mock_pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.50,<3.60")) |
| 14 | + assert mock_pulp_ctx.has_plugin( |
| 15 | + PluginRequirement("core", specifier=">=3.50,<3.60", inverted=True) |
| 16 | + ) |
| 17 | + |
| 18 | + assert not mock_pulp_ctx.has_plugin(PluginRequirement("elephant")) |
| 19 | + assert not mock_pulp_ctx.has_plugin(PluginRequirement("elephant", specifier=">=0.0.0")) |
| 20 | + assert mock_pulp_ctx.has_plugin( |
| 21 | + PluginRequirement("elephant", specifier=">=0.0.0", inverted=True) |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +def test_needs_plugin(mock_pulp_ctx: PulpContext) -> None: |
| 26 | + mock_pulp_ctx.needs_plugin(PluginRequirement("core")) |
| 27 | + mock_pulp_ctx.needs_plugin(PluginRequirement("elephant", feature="zoo")) |
| 28 | + with pytest.raises(PulpException, match=r"elephant.*zoo"): |
| 29 | + mock_pulp_ctx.has_plugin(PluginRequirement("core")) |
0 commit comments