From 79c5cc0e85572d10bdde0c3779da906d3eda023b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Redzy=C5=84ski?= Date: Tue, 27 Nov 2018 08:15:36 +0100 Subject: [PATCH] fix and test outdate check (#1368) * fix and test outdate check * split test cases --- dvc/updater.py | 10 +++++++--- tests/test_updater.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dvc/updater.py b/dvc/updater.py index ec1ee1870..5e5cd3505 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -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 = ( diff --git a/tests/test_updater.py b/tests/test_updater.py index 889294b23..d3e372ada 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -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())