diff --git a/awslimitchecker/tests/test_versioncheck.py b/awslimitchecker/tests/test_versioncheck.py index 4e3dc294..cdd5f7c3 100644 --- a/awslimitchecker/tests/test_versioncheck.py +++ b/awslimitchecker/tests/test_versioncheck.py @@ -900,6 +900,42 @@ def test_find_package_version_no_debug(self): ] assert mock_is_git.mock_calls == [call()] + def test_is_git_clone_true(self): + foo_path = '/foo/bar/awslimitchecker/awslimitchecker/versioncheck.pyc' + + with patch.multiple( + '%s.os.path' % self.mpb, + abspath=DEFAULT, + exists=DEFAULT, + ) as mocks: + mocks['abspath'].return_value = foo_path + mocks['exists'].return_value = True + cls = AGPLVersionChecker() + res = cls._is_git_clone + assert res is True + assert mocks['abspath'].call_count == 1 + assert mocks['exists'].mock_calls == [ + call('/foo/bar/awslimitchecker/.git') + ] + + def test_is_git_clone_false(self): + foo_path = '/foo/bar/awslimitchecker/awslimitchecker/versioncheck.pyc' + + with patch.multiple( + '%s.os.path' % self.mpb, + abspath=DEFAULT, + exists=DEFAULT, + ) as mocks: + mocks['abspath'].return_value = foo_path + mocks['exists'].return_value = False + cls = AGPLVersionChecker() + res = cls._is_git_clone + assert res is False + assert mocks['abspath'].call_count == 1 + assert mocks['exists'].mock_calls == [ + call('/foo/bar/awslimitchecker/.git') + ] + class Test_VersionCheck_Funcs(object): """ diff --git a/awslimitchecker/versioncheck.py b/awslimitchecker/versioncheck.py index f242d5c9..4d920f0f 100644 --- a/awslimitchecker/versioncheck.py +++ b/awslimitchecker/versioncheck.py @@ -146,7 +146,14 @@ def _is_git_clone(self): :rtype: bool :returns: True if installed via git, False otherwise """ - return True + distpath = os.path.normpath( + os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../' + ) + ) + gitpath = os.path.join(distpath, '.git') + return os.path.exists(gitpath) def _find_pkg_info(self): """