@patch('teuthology.suite.util.requests.get')
def test_find_git_parents(self, m_requests_get):
- refresh_resp = Mock(ok=True)
history_resp = Mock(ok=True)
history_resp.json.return_value = {'sha1s': ['sha1', 'sha1_p']}
- m_requests_get.side_effect = [refresh_resp, history_resp]
+ m_requests_get.return_value = history_resp
parent_sha1s = util.find_git_parents('ceph', 'sha1')
- assert len(m_requests_get.mock_calls) == 2
+ assert m_requests_get.call_count == 1
assert parent_sha1s == ['sha1_p']
log.warning('githelper_base_url not set, --newest disabled')
return []
- def refresh(project):
- url = '%s/%s.git/refresh/' % (base_url, project)
- resp = requests.get(url)
- if not resp.ok:
- log.error('git refresh failed for %s: %s',
- project, resp.content.decode())
-
def get_sha1s(project, committish, count):
url = '/'.join((base_url, '%s.git' % project,
'history/?committish=%s&count=%d' % (committish, count)))
int(count), sha1, project, resp.json()['error'])
return sha1s
- refresh(project)
# index 0 will be the commit whose parents we want to find.
# So we will query for count+1, and strip index 0 from the result.
sha1s = get_sha1s(project, sha1, count + 1)