From 0ff8463339f9c0423e749ad06eb38d2ff8e952c5 Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Mon, 30 Dec 2024 09:55:34 -0600 Subject: [PATCH] parameterize test --- tests/tests_unit/test_config_set.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/tests_unit/test_config_set.py b/tests/tests_unit/test_config_set.py index e14200994d..9ad9633ac8 100644 --- a/tests/tests_unit/test_config_set.py +++ b/tests/tests_unit/test_config_set.py @@ -8,18 +8,27 @@ test_version = "2024.12.2" -def test_valid_version_requirement(): - metadata = ConfigSetMetadata( - name="test-config", nebari_version=">=2024.12.0,<2025.0.0" - ) - assert metadata.nebari_version.specifier.contains(test_version) +test_version = "2024.12.2" -def test_invalid_version_requirement(): - with pytest.raises(ValueError) as exc_info: - csm = ConfigSetMetadata(name="test-config", nebari_version=">=2025.0.0") - csm.check_version(test_version) - assert "Current Nebari version" in str(exc_info.value) +@pytest.mark.parametrize( + "version_input,should_pass", + [ + (">=2024.12.0,<2025.0.0", True), + (Requirement("nebari>=2024.12.0,<2025.0.0"), True), + (">=2025.0.0", False), + (Requirement("nebari>=2025.0.0"), False), + ], +) +def test_version_requirement(version_input, should_pass): + metadata = ConfigSetMetadata(name="test-config", nebari_version=version_input) + + if should_pass: + metadata.check_version(test_version) + else: + with pytest.raises(ValueError) as exc_info: + metadata.check_version(test_version) + assert "Current Nebari version" in str(exc_info.value) def test_valid_version_requirement_with_requirement_object():