fix and test outdate check (#1368)

* fix and test outdate check

* split test cases
This commit is contained in:
Paweł Redzyński
2018-11-27 09:15:36 +02:00
committed by Ruslan Kuprieiev
parent eac86b5b4f
commit 79c5cc0e85
2 changed files with 25 additions and 3 deletions
+7 -3
View File
@@ -92,9 +92,13 @@ class Updater(object): # pragma: no cover
l_major, l_minor, l_patch = [int(x) for x in self.latest.split('.')]
c_major, c_minor, c_patch = [int(x) for x in self.current.split('.')]
return (l_major > c_major or
l_minor > c_minor or
l_patch > c_patch)
if l_major != c_major:
return l_major > c_major
if l_minor != c_minor:
return l_minor > c_minor
return l_patch > c_patch
def _notify(self):
message = (
+18
View File
@@ -23,3 +23,21 @@ class TestUpdater(TestDvc):
self.dvc.updater.check()
os.environ = env.copy()
def test_check_version_newer(self):
self.dvc.updater.latest = "0.20.8"
self.dvc.updater.current = "0.21.0"
self.assertFalse(self.dvc.updater._is_outdated())
def test_check_version_equal(self):
self.dvc.updater.latest = "0.20.8"
self.dvc.updater.current = "0.20.8"
self.assertFalse(self.dvc.updater._is_outdated())
def test_check_version_outdated(self):
self.dvc.updater.latest = "0.21.0"
self.dvc.updater.current = "0.20.8"
self.assertTrue(self.dvc.updater._is_outdated())