def downwards(self, owner, repository_name): number_of_days_to_get_commits_for = 7 from flask import current_app from datetime import datetime, timedelta from githubclient.const import GITHUB_COMMITS_URL_MASK, DATETIME_FORMAT until = datetime.today() since = until - timedelta(days=number_of_days_to_get_commits_for) url = current_app.config[GITHUB_COMMITS_URL_MASK].format(owner, repository_name, since.strftime(DATETIME_FORMAT), until.strftime(DATETIME_FORMAT)) from githubclient import request_util, util, json_parser stats = request_util.get_per_page(url, util.define_last_page()) urls = map(lambda stat: stat['url'], stats) commits = self.__pool.map(lambda commit_url: json_parser.commit_from_json(request_util.get(commit_url)), urls) return util.deletions_more_than_additions(commits)
def test_deletions_more_than_additions_should_return_true_if_additions_less_than_deletions(self): self.assertTrue(util.deletions_more_than_additions([ Commit(1, 10), Commit(2, 9) ]))
def test_deletions_more_than_additions_should_return_false_on_equal_additions_and_deletions(self): self.assertFalse(util.deletions_more_than_additions([ Commit(2, 6), Commit(3, 8), Commit(9, 0) ]))
def test_deletions_more_than_additions_should_return_true_if_deletions_more_than_additions(self): self.assertFalse(util.deletions_more_than_additions([ Commit(15, 6), Commit(7, 8), Commit(9, 1) ]))
def test_deletions_more_than_additions_should_return_false_on_empty_list(self): self.assertEquals(False, util.deletions_more_than_additions([]))