-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
143 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
"""Test equals.""" | ||
import pytest | ||
|
||
from awesomeversion import AwesomeVersion | ||
|
||
|
||
def test_equals(): | ||
@pytest.mark.parametrize( | ||
"version", | ||
[ | ||
("1"), | ||
("2020.12.1"), | ||
("2020"), | ||
("2021.2.0b0"), | ||
("2021.2.0.dev20210118"), | ||
], | ||
) | ||
def test_equals(version): | ||
"""Test equals.""" | ||
assert AwesomeVersion("2020.12.1") == AwesomeVersion("2020.12.1") | ||
assert AwesomeVersion("2020") == AwesomeVersion("2020") | ||
assert AwesomeVersion("2020") == AwesomeVersion("v2020") | ||
assert AwesomeVersion("2020") == AwesomeVersion("V2020") | ||
assert AwesomeVersion("2020") != AwesomeVersion("2021") | ||
assert str(AwesomeVersion("2021.2.0b0")) == "2021.2.0b0" | ||
assert AwesomeVersion("2021.2.0b0").string == "2021.2.0b0" | ||
assert str(AwesomeVersion("2021.2.0.dev20210118")) == "2021.2.0.dev20210118" | ||
assert AwesomeVersion("2021.2.0.dev20210118").string == "2021.2.0.dev20210118" | ||
version_object = AwesomeVersion(version) | ||
assert version_object == version | ||
assert str(version_object) == version | ||
assert version_object.string == version | ||
assert version_object == AwesomeVersion(f"v{version}") | ||
assert version_object == AwesomeVersion(f"v{version}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
"""Test match.""" | ||
import pytest | ||
|
||
from awesomeversion.match import version_strategy | ||
from awesomeversion import AwesomeVersion | ||
from awesomeversion.strategy import AwesomeVersionStrategy | ||
|
||
test_data = [ | ||
("123", AwesomeVersionStrategy.BUILDVER), | ||
("20.1.0", AwesomeVersionStrategy.CALVER), | ||
("0.118.0", AwesomeVersionStrategy.SEMVER), | ||
("1.2.3.4.5", AwesomeVersionStrategy.SIMPLEVER), | ||
("string", AwesomeVersionStrategy.UNKNOWN), | ||
("latest", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("stable", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("beta", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("dev", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("version,strategy", test_data) | ||
@pytest.mark.parametrize( | ||
"version,strategy", | ||
[ | ||
("0.118.0", AwesomeVersionStrategy.SEMVER), | ||
("1.2.3.4.5", AwesomeVersionStrategy.SIMPLEVER), | ||
("123", AwesomeVersionStrategy.BUILDVER), | ||
("20.1.0", AwesomeVersionStrategy.CALVER), | ||
("beta", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("dev", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("latest", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("stable", AwesomeVersionStrategy.SPECIALCONTAINER), | ||
("string", AwesomeVersionStrategy.UNKNOWN), | ||
], | ||
) | ||
def test_strategy_match(version, strategy): | ||
"""Test that the version matches the expected strategy.""" | ||
assert version_strategy(version) == strategy | ||
assert AwesomeVersion(version).strategy == strategy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Test test_version_scheme.""" | ||
import pytest | ||
|
||
from awesomeversion import AwesomeVersion | ||
from awesomeversion.strategy import AwesomeVersionStrategy | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"version,strategy,dev,beta,modifier,modifier_type", | ||
[ | ||
("0.118.0", AwesomeVersionStrategy.SEMVER, False, False, None, None), | ||
("1.0.0-beta.1", AwesomeVersionStrategy.SEMVER, False, True, "beta.1", "beta"), | ||
("v1.0.0-beta.1", AwesomeVersionStrategy.SEMVER, False, True, "beta.1", "beta"), | ||
("2021.2.0.dev1", AwesomeVersionStrategy.CALVER, True, False, "dev1", "dev"), | ||
("stable", AwesomeVersionStrategy.SPECIALCONTAINER, False, False, None, None), | ||
], | ||
) | ||
def test_version_scheme(version, strategy, dev, beta, modifier, modifier_type): | ||
"""Test that the version matches the expected scheme.""" | ||
version_object = AwesomeVersion(version) | ||
assert str(version_object) == version | ||
assert version_object.strategy == strategy | ||
assert version_object.dev == dev | ||
assert version_object.beta == beta | ||
assert version_object.modifier == modifier | ||
assert version_object.modifier_type == modifier_type |