def test409Exception(self): """Test FetchUrlJson raises 409 errors with response body message.""" with self.assertRaises(gob_util.GOBError) as ex: gob_util.FetchUrlJson( site_config.params.EXTERNAL_GERRIT_HOST, 'changes/422652/revisions/901b4ee349a9395ba23a7a1e8597a35050f741e4/' 'review', reqtype='POST', body={'labels': { 'Trybot-Ready': '+1' }}) self.assertEqual(ex.exception.http_status, 409) self.assertEqual(ex.exception.reason, gob_util.GOB_ERROR_REASON_CLOSED_CHANGE)
def GetLatestRelease(git_url, branch=None): """Gets the latest release version from the release tags in the repository. Args: git_url: URL of git repository. branch: If set, gets the latest release for branch, otherwise latest release. Returns: Latest version string. """ # TODO(szager): This only works for public release buildspecs in the chromium # src repository. Internal buildspecs are tracked differently. At the time # of writing, I can't find any callers that use this method to scan for # internal buildspecs. But there may be something lurking... parsed_url = urlparse.urlparse(git_url) path = parsed_url[2].rstrip('/') + '/+refs/tags?format=JSON' j = gob_util.FetchUrlJson(parsed_url[1], path, ignore_404=False) if branch: chrome_version_re = re.compile(r'^%s\.\d+.*' % branch) else: chrome_version_re = re.compile(r'^[0-9]+\..*') matching_versions = [ key for key in j.keys() if chrome_version_re.match(key) ] matching_versions.sort(key=distutils.version.LooseVersion) for chrome_version in reversed(matching_versions): path = parsed_url[2].rstrip() + ('/+/refs/tags/%s/DEPS?format=text' % chrome_version) fh = gob_util.FetchUrl(parsed_url[1], path, ignore_404=False) content = fh.read() if fh else None if content: deps_content = base64.b64decode(content) if CheckIfChromeRightForOS(deps_content): return chrome_version return None
def test404Exception(self): with self.assertRaises(gob_util.GOBError) as ex: gob_util.FetchUrlJson(site_config.params.EXTERNAL_GOB_HOST, 'foo/bar/baz', ignore_404=False) self.assertEqual(ex.exception.http_status, 404)
def test404(self): gob_util.FetchUrlJson(site_config.params.EXTERNAL_GOB_HOST, 'foo/bar/baz')
def test200(self): """Test successful loading of change.""" gob_util.FetchUrlJson(site_config.params.EXTERNAL_GOB_HOST, 'changes/227254/detail')
def test404(self): gob_util.FetchUrlJson(config_lib.GetSiteParams().EXTERNAL_GOB_HOST, 'foo/bar/baz')
def test200(self): """Test successful loading of change.""" gob_util.FetchUrlJson(config_lib.GetSiteParams().EXTERNAL_GOB_HOST, 'changes/227254/detail')