Skip to content

Commit

Permalink
Moodle update progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamJoan committed Mar 17, 2017
1 parent 0a3fc2c commit 4b847fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dscan/common/update_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def github_tags_newer(github_repo, versions_file, update_majors):
after = tag.text

newer = _newer_tags_get(current_highest, gh_versions)
if(len(newer) > 0):
if len(newer) > 0:
return True

pages_done += 1
Expand Down Expand Up @@ -114,6 +114,7 @@ def _newer_tags_get(current_highest, versions):
for major in current_highest:
highest_version = current_highest[major]
for version in versions:
version = version.lstrip('v')
if version.startswith(major) and version_gt(version,
highest_version):
newer.append(version)
Expand Down
17 changes: 15 additions & 2 deletions dscan/tests/update_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dscan.common.testutils import decallmethods
from dscan.common.update_api import GH, UW
from dscan.common.update_api import github_tags_newer, github_repo, _github_normalize, \
file_mtime, modules_get, _tag_is_rubbish
file_mtime, modules_get, _tag_is_rubbish, _newer_tags_get
from datetime import datetime, timedelta
from dscan.common.update_api import GitRepo
from dscan import common
Expand Down Expand Up @@ -121,7 +121,6 @@ def test_github_tag_newer_multi_page(self):
# should be true because of 5.9 in response mocks.
assert github_tags_newer('drupal/drupal/', 'not_a_real_file.xml', ['6', '7', '5'])


def test_github_repo(self):
with patch('dscan.common.update_api.GitRepo.__init__', return_value=None, autospec=True) as gri:
with patch('dscan.common.update_api.GitRepo.init', autospec=True) as grii:
Expand Down Expand Up @@ -619,3 +618,17 @@ def test_wordpress_plugins_get(self):
print(len(plugins), len(themes))
assert len(plugins) == 1000
assert len(themes) == 1997

def test_moodle_strip_prefix(self):
versions = [u'v3.2.2', u'v3.1.5', u'v3.0.9', u'v3.2.1', u'v3.1.4',
u'v3.0.8', u'v3.2.0', u'v3.2.0-rc5']

current_highest = {
'3.2': '3.2rc4',
'3.3': '3.2.9999',
'3.0': '3.0.7',
'3.1': '3.1.3'
}

assert _newer_tags_get(current_highest, versions)

0 comments on commit 4b847fd

Please sign in to comment.