Skip to content

Commit

Permalink
Add test and fix failing tests #101
Browse files Browse the repository at this point in the history
Reference: #101

Signed-off-by: John M. Horan <[email protected]>
  • Loading branch information
johnmhoran committed Feb 23, 2023
1 parent d71d003 commit 0c3283b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/univers/version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,5 +1244,5 @@ def build_range_from_github_advisory_constraint(scheme: str, string: str):
"nuget": "nuget",
"pypi": "pypi",
"packagist": "composer",
"conan": "conan1",
"conan1": "conan1",
}
22 changes: 17 additions & 5 deletions tests/test_version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from univers.version_constraint import VersionConstraint
from univers.version_range import RANGE_CLASS_BY_SCHEMES
from univers.version_range import Conan1VersionRange
from univers.version_range import GemVersionRange
from univers.version_range import InvalidVersionRange
from univers.version_range import MattermostVersionRange
Expand All @@ -20,6 +21,7 @@
from univers.version_range import PypiVersionRange
from univers.version_range import VersionRange
from univers.version_range import from_gitlab_native
from univers.versions import InvalidVersion
from univers.versions import NugetVersion
from univers.versions import OpensslVersion
from univers.versions import PypiVersion
Expand Down Expand Up @@ -353,6 +355,19 @@ def test_pypi_gitlab_version_range_parse(test_case):
assert str(result) == test_case["expected_vers"]


@pytest.mark.parametrize("test_case", json.load(open("./tests/data/conan_advisory.json")))
def test_conan_gitlab_version_range_parse(test_case):
if test_case["expected_vers"] is None:
with pytest.raises(InvalidVersion):
Conan1VersionRange.from_native(string=test_case["native"])
return
result = from_gitlab_native(
gitlab_scheme=test_case["scheme"],
string=test_case["native"],
)
assert str(result) == test_case["expected_vers"]


@pytest.mark.parametrize("test_case", json.load(open("./tests/data/npm_gitlab.json")))
def test_npm_gitlab_version_range_parse(test_case):
result = from_gitlab_native(
Expand Down Expand Up @@ -400,13 +415,10 @@ def test_npm_advisory_version_range_parse(test_case):
@pytest.mark.parametrize("test_case", json.load(open("./tests/data/conan_advisory.json")))
def test_conan_advisory_version_range_parse(test_case):
if test_case["expected_vers"] is None:
# with pytest.raises(InvalidVersionRange):
with pytest.raises(InvalidVersion):
# ConanVersionRange.from_native(string=test_case["conan_native"])
ConanVersionRange.from_native(string=test_case["native"])
Conan1VersionRange.from_native(string=test_case["native"])
return
result = ConanVersionRange.from_native(
# string=test_case["conan_native"],
result = Conan1VersionRange.from_native(
string=test_case["native"],
)
assert str(result) == test_case["expected_vers"]
Expand Down

0 comments on commit 0c3283b

Please sign in to comment.