def test_get_releases(self): """ _test_get_releases_ """ resp_json = [{'tag_name': self.release}] mock_req = mock.Mock() mock_req.raise_for_status.return_value = False mock_req.json.return_value = resp_json self.mock_get.return_value = mock_req result = get_releases(self.owner, self.repo, 'token') self.failUnless(self.mock_get.called) self.failUnless('tag_name' in result[0])
def latest_release(config): """ _latest_release_ pull list of releases from GH repo, pick the newest by publication date. """ releases = get_releases(config.organisation_name(), config.package_name()) tags = [(release['tag_name'], release['published_at']) for release in releases] sorted(tags, key=sort_by_date) most_recent_tag = tags[0][0] return most_recent_tag
def test_get_releases(self): """ _test_get_releases_ """ resp_json = [ {'tag_name': self.release} ] mock_req = mock.Mock() mock_req.raise_for_status.return_value = False mock_req.json.return_value = resp_json self.mock_get.return_value = mock_req result = get_releases(self.owner, self.repo, 'token') self.failUnless(self.mock_get.called) self.failUnless('tag_name' in result[0])