Skip to content

Commit

Permalink
fixed updatechecker
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Nov 17, 2024
1 parent 61fca7e commit 5fa2fbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cat_win/src/web/updatechecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def only_alpha(_s: str) -> str:
only alpha chars and 'z'
"""
x = 'abcdefghijklmnopqrstuvwxyz'
return ''.join(filter(lambda c: c in x, _s.lower())) + 'z'
return ''.join(filter(lambda c: c in x, _s.lower()))


def gen_version_tuples(_v: str, _w: str) -> tuple:
Expand Down Expand Up @@ -171,6 +171,9 @@ def new_version_available(current_version: str, latest_version: str) -> int:
if c_alpha < l_alpha:
status = STATUS_PRE_RELEASE_AVAILABLE
break
if c_alpha > l_alpha and all(l.isdigit() for l in latest[i-1:]):
status = STATUS_STABLE_RELEASE_AVAILABLE
break
if i < len(current):
status *= -1
return status
Expand Down
2 changes: 2 additions & 0 deletions cat_win/tests/src/web/test_updatechecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_version_comparison_stable_release(self):
self.assertEqual(updatechecker.new_version_available('1.0.12', '1.000.020'), 1)
self.assertEqual(updatechecker.new_version_available('v1.0.0', 'v01.00.01'), 1)
self.assertEqual(updatechecker.new_version_available('2.1.5a', '2.1.6'), 1)
self.assertEqual(updatechecker.new_version_available('2.1.6a', '2.1.6'), 1)
self.assertEqual(updatechecker.new_version_available('v2.1b.5a', '2.1b.051'), 1)

def test_version_comparison_pre_release(self):
Expand All @@ -62,6 +63,7 @@ def test_version_comparison_stable_release_unsafe(self):
self.assertEqual(updatechecker.new_version_available('1.0.15', '1.1.9'), -1)
self.assertEqual(updatechecker.new_version_available('1.0.9', 'v2.0.9'), -1)
self.assertEqual(updatechecker.new_version_available('1.0.12', '1.001.0'), -1)
self.assertEqual(updatechecker.new_version_available('1.10a.0', '1.10.0'), -1)
self.assertEqual(updatechecker.new_version_available('v1.0.0', 'v01.001.01'), -1)
self.assertEqual(updatechecker.new_version_available('2.1.5a', '2.2.5'), -1)

Expand Down

0 comments on commit 5fa2fbd

Please sign in to comment.