def test_revision_to_branched_from_no_branched_from(self, mock_get_url_content): """Test revision_to_branched_from() where commit has no branch-from""" mock_get_url_content.side_effect = self.mock_get_url_content val = revisions.revision_to_branched_from('https://test-repository/src.git', 'f00d') self.assertEqual(None, val)
def get_component_impacts_from_url(component_name, regression_range, job_type, platform=None): """Gets component impact string using the build information url.""" logs.log('Getting component impacts from URL. Component name %s, ' 'regression range %s, job type %s, platform %s.' % (component_name, regression_range, str(job_type), str(platform))) start_revision, end_revision = get_start_and_end_revision( regression_range, job_type) logs.log('Start and end revision %s, %s' % (start_revision, end_revision)) if not end_revision: return Impacts() build_revision_mappings = build_info.get_build_to_revision_mappings(platform) if not build_revision_mappings: return Impacts() found_impacts = dict() for build in ['extended_stable', 'stable', 'beta', 'canary']: mapping = build_revision_mappings.get(build) logs.log('Considering impacts for %s.' % (build)) # TODO(yuanjunh): bypass for now but remove it after ES is enabled. if build == 'extended_stable' and not mapping: found_impacts[build] = Impact() continue # Some platforms don't have canary, so use dev to represent # the affected head version. if build == 'canary' and not mapping: mapping = build_revision_mappings.get('dev') if not mapping: return Impacts() chromium_revision = mapping['revision'] logs.log('Chromium revision is %s.' % (chromium_revision)) component_revision = get_component_information_by_name( chromium_revision, component_name) logs.log('Component revision is %s.' % (component_revision)) if not component_revision: return Impacts() branched_from = revisions.revision_to_branched_from( component_revision['url'], component_revision['rev']) logs.log('Branched from revision is %s.' % (branched_from)) if not branched_from: # This is a head revision, not branched. branched_from = component_revision['rev'] impact = get_impact({ 'revision': branched_from, 'version': mapping['version'] }, start_revision, end_revision, build == 'canary') logs.log('Resulting impact is %s.' % (str(impact))) found_impacts[build] = impact return Impacts(found_impacts['stable'], found_impacts['beta'], found_impacts['extended_stable'], found_impacts['canary'])
def get_component_impacts_from_url(component_name, regression_range, job_type, platform=None): """Gets component impact string using the build information url.""" start_revision, end_revision = get_start_and_end_revision( regression_range, job_type) if not end_revision: return Impacts() build_revision_mappings = build_info.get_build_to_revision_mappings( platform) if not build_revision_mappings: return Impacts() found_impacts = dict() for build in ['extended_stable', 'stable', 'beta', 'canary']: mapping = build_revision_mappings.get(build) # TODO(yuanjunh): bypass for now but remove it after ES is enabled. if build == 'extended_stable' and not mapping: found_impacts[build] = Impact() continue # Some platforms don't have canary, so use dev to represent # the affected head version. if build == 'canary' and not mapping: mapping = build_revision_mappings.get('dev') if not mapping: return Impacts() chromium_revision = mapping['revision'] component_revision = get_component_information_by_name( chromium_revision, component_name) if not component_revision: return Impacts() branched_from = revisions.revision_to_branched_from( component_revision['url'], component_revision['rev']) if not branched_from: # This is a head revision, not branched. branched_from = component_revision['rev'] impact = get_impact( { 'revision': branched_from, 'version': mapping['version'] }, start_revision, end_revision, build == 'canary') found_impacts[build] = impact return Impacts(found_impacts['stable'], found_impacts['beta'], found_impacts['extended_stable'], found_impacts['canary'])
def test_revision_to_branched_from_no_message(self, mock_get_url_content): """Test revision_to_branched_from() with no commit message at all""" mock_get_url_content.side_effect = self.mock_get_url_content val = revisions.revision_to_branched_from('https://test-repository/src.git', 'd00d') self.assertEqual(None, val)
def test_revision_to_branched_from(self, mock_get_url_content): """Test revision_to_branched_from() with normal branch.""" mock_get_url_content.side_effect = self.mock_get_url_content val = revisions.revision_to_branched_from('https://test-repository/src.git', 'abcd') self.assertEqual('36884', val)