Skip to content

Commit

Permalink
parameterize test
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-D-Lewis committed Dec 30, 2024
1 parent 09c6bab commit 0ff8463
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions tests/tests_unit/test_config_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 0ff8463

Please sign in to comment.