Skip to content

Commit

Permalink
first try at a real fix for #73
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Nov 26, 2015
1 parent 9be21a5 commit 87624b7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
36 changes: 36 additions & 0 deletions awslimitchecker/tests/test_versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
9 changes: 8 additions & 1 deletion awslimitchecker/versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 87624b7

Please sign in to comment.