return resp.text.strip()
-def github_branch_exists(project, branch, project_owner='ceph'):
+def build_git_url(project, project_owner='ceph'):
"""
- Query GitHub to check the existence of a project's branch
+ Return the git URL to clone the project
"""
if project == 'ceph-qa-suite':
base = config.get_ceph_qa_suite_git_url()
base = config.get_ceph_git_url()
else:
base = 'https://github.com/{project_owner}/{project}'
- url_templ = re.sub('\.git$', '', base) + '/tree/{branch}'
- url = url_templ.format(project_owner=project_owner, project=project,
- branch=branch)
+ url_templ = re.sub('\.git$', '', base)
+ return url_templ.format(project_owner=project_owner, project=project)
+
+def github_branch_exists(project, branch, project_owner='ceph'):
+ """
+ Query GitHub to check the existence of a project's branch
+ """
+ url = build_git_url(project, project_owner) + '/tree/' + branch
resp = requests.head(url)
return resp.ok
result = suite.combine_path("/path/to/left", None)
assert result == "/path/to/left"
+ def test_build_git_url_github(self):
+ assert 'project' in suite.build_git_url('project')
+ owner = 'OWNER'
+ assert owner in suite.build_git_url('project', project_owner=owner)
+
+ @patch('teuthology.config.TeuthologyConfig.get_ceph_qa_suite_git_url')
+ def test_build_git_url_ceph_qa_suite_custom(self, m_get_ceph_qa_suite_git_url):
+ url = 'http://foo.com/some'
+ m_get_ceph_qa_suite_git_url.return_value = url + '.git'
+ assert url == suite.build_git_url('ceph-qa-suite')
+
+ @patch('teuthology.config.TeuthologyConfig.get_ceph_git_url')
+ def test_build_git_url_ceph_custom(self, m_get_ceph_git_url):
+ url = 'http://foo.com/some'
+ m_get_ceph_git_url.return_value = url + '.git'
+ assert url == suite.build_git_url('ceph')
class TestFlavor(object):
def test_get_install_task_flavor_bare(self):
assert fragments[0] == 'thrash/ceph/base.yaml'
assert fragments[1] == 'thrash/ceph-thrash/default.yaml'
+def test_github_branch_exists():
+ assert False == suite.github_branch_exists('ceph', 'nobranchnowaycanthappen')
+ assert True == suite.github_branch_exists('ceph', 'master')
class TestSuiteMain(object):