-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 783-fix-download-authentication-feeds
- Loading branch information
Showing
160 changed files
with
20,519 additions
and
1,182 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from packaging.version import Version | ||
|
||
|
||
def compare_java_versions(v1: str | None, v2: str | None): | ||
""" | ||
Compare two version strings v1 and v2. | ||
Returns 1 if v1 > v2, -1 if v1 < v2, | ||
otherwise 0. | ||
The version strings are expected to be in the format of | ||
major.minor.patch[-SNAPSHOT] | ||
""" | ||
if v1 is None and v2 is None: | ||
return 0 | ||
if v1 is None: | ||
return -1 | ||
if v2 is None: | ||
return 1 | ||
# clean version strings replacing the SNAPSHOT suffix with .dev0 | ||
v1 = v1.replace("-SNAPSHOT", ".dev0") | ||
v2 = v2.replace("-SNAPSHOT", ".dev0") | ||
if Version(v1) > Version(v2): | ||
return 1 | ||
elif Version(v1) < Version(v2): | ||
return -1 | ||
else: | ||
return 0 |
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
from utils.model_utils import compare_java_versions | ||
|
||
|
||
class TestCompareJavaVersions(unittest.TestCase): | ||
def test_compare_versions_equal(self): | ||
self.assertEqual(compare_java_versions("1.0.0", "1.0.0"), 0) | ||
self.assertEqual(compare_java_versions("1.0.0-SNAPSHOT", "1.0.0-SNAPSHOT"), 0) | ||
|
||
def test_compare_versions_v1_greater(self): | ||
self.assertEqual(compare_java_versions("1.0.1", "1.0.0"), 1) | ||
self.assertEqual(compare_java_versions("1.0.0", "0.9.9"), 1) | ||
self.assertEqual(compare_java_versions("1.0.0", "1.0.0-SNAPSHOT"), 1) | ||
|
||
def test_compare_versions_v2_greater(self): | ||
self.assertEqual(compare_java_versions("1.0.0", "1.0.1"), -1) | ||
self.assertEqual(compare_java_versions("0.9.9", "1.0.0"), -1) | ||
self.assertEqual(compare_java_versions("1.0.0-SNAPSHOT", "1.0.0"), -1) | ||
|
||
def test_compare_versions_with_none(self): | ||
self.assertEqual(compare_java_versions(None, None), 0) | ||
self.assertEqual(compare_java_versions(None, "1.0.0"), -1) | ||
self.assertEqual(compare_java_versions("1.0.0", None), 1) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Oops, something went wrong.