def test_get_impacts_known_component_es_not_exists(self):
        """Test getting impacts for a known component
    when extended stable doesn't exists."""
        self.mock.get_component_name.return_value = 'v8'
        self.mock.get_impact.side_effect = [
            impact_task.Impact('s', False),
            impact_task.Impact('b', True)
        ]
        impacts = impact_task.get_impacts_from_url('123:456', 'job', 'windows')

        self.assertEqual('', impacts.extended_stable.version)
        self.assertFalse(impacts.extended_stable.likely)
        self.assertEqual('s', impacts.stable.version)
        self.assertFalse(impacts.stable.likely)
        self.assertEqual('b', impacts.beta.version)
        self.assertTrue(impacts.beta.likely)

        self.mock.get_start_and_end_revision.assert_has_calls(
            [mock.call('123:456', 'job')])
        self.mock.get_build_to_revision_mappings.assert_has_calls(
            [mock.call('windows')])
        self.mock.get_impact.assert_has_calls([
            mock.call({
                'version': '74.0.1345.34',
                'revision': '666666'
            }, 1, 100),
            mock.call({
                'version': '75.0.1353.43',
                'revision': '777777'
            }, 1, 100)
        ])
    def test_get_impacts_canary_not_exists(self):
        """Test getting impacts when extended stable exists."""
        self.mock.get_build_to_revision_mappings.return_value = {
            'extended_stable': {
                'revision': '398287',
                'version': '74.0.1345.34'
            },
            'stable': {
                'revision': '398287',
                'version': '74.0.1345.34'
            },
            'beta': {
                'revision': '399171',
                'version': '75.0.1353.43'
            },
            'dev': {
                'revision': '400000',
                'version': '76.0.1234.43'
            }
        }
        self.mock.get_impact.side_effect = [
            impact_task.Impact('es', False),
            impact_task.Impact('s', False),
            impact_task.Impact('b', True),
            impact_task.Impact('d', False)
        ]

        impacts = impact_task.get_impacts_from_url('123:456', 'job', 'windows')

        self.assertEqual('es', impacts.extended_stable.version)
        self.assertFalse(impacts.extended_stable.likely)
        self.assertEqual('s', impacts.stable.version)
        self.assertFalse(impacts.stable.likely)
        self.assertEqual('b', impacts.beta.version)
        self.assertTrue(impacts.beta.likely)
        self.assertEqual('d', impacts.head.version)
        self.assertFalse(impacts.head.likely)

        self.mock.get_start_and_end_revision.assert_has_calls(
            [mock.call('123:456', 'job')])
        self.mock.get_build_to_revision_mappings.assert_has_calls(
            [mock.call('windows')])
        self.mock.get_impact.assert_has_calls([
            mock.call({
                'version': '74.0.1345.34',
                'revision': '398287'
            }, 1, 100),
            mock.call({
                'version': '74.0.1345.34',
                'revision': '398287'
            }, 1, 100),
            mock.call({
                'version': '75.0.1353.43',
                'revision': '399171'
            }, 1, 100),
            mock.call({
                'version': '76.0.1234.43',
                'revision': '400000'
            }, 1, 100)
        ])
    def test_get_impacts_es_not_exists(self):
        """Test getting impacts when extended stable doesn't exist."""
        impacts = impact_task.get_impacts_from_url('123:456', 'job', 'windows')

        self.assertEqual('', impacts.extended_stable.version)
        self.assertFalse(impacts.extended_stable.likely)
        self.assertEqual('s', impacts.stable.version)
        self.assertFalse(impacts.stable.likely)
        self.assertEqual('b', impacts.beta.version)
        self.assertTrue(impacts.beta.likely)

        self.mock.get_start_and_end_revision.assert_has_calls(
            [mock.call('123:456', 'job')])
        self.mock.get_build_to_revision_mappings.assert_has_calls(
            [mock.call('windows')])
        self.mock.get_impact.assert_has_calls([
            mock.call(None, 1, 100),
            mock.call({
                'version': '74.0.1345.34',
                'revision': '398287'
            }, 1, 100),
            mock.call({
                'version': '75.0.1353.43',
                'revision': '399171'
            }, 1, 100)
        ])
 def test_bail_out_unknown_component(self):
     """Test bailing out when having an unknown component."""
     self.mock.get_component_name.return_value = 'com'
     self.assertTrue(
         impact_task.get_impacts_from_url('123:456', 'job').is_empty())
     self.mock.get_start_and_end_revision.assert_has_calls([])
     self.mock.get_build_to_revision_mappings.assert_has_calls([])
     self.mock.get_impact.assert_has_calls([])
 def test_bail_out_end_revision(self):
     """Test bailing out when there's no end_revision."""
     self.mock.get_start_and_end_revision.return_value = (1, None)
     self.assertTrue(
         impact_task.get_impacts_from_url('123:456', 'job').is_empty())
     self.mock.get_start_and_end_revision.assert_has_calls(
         [mock.call('123:456', 'job')])
     self.mock.get_build_to_revision_mappings.assert_has_calls([])
     self.mock.get_impact.assert_has_calls([])
 def test_bail_out_no_component_branched_from(self):
     """Test bailing out when there's no Cr-Branched-From."""
     self.mock.get_component_name.return_value = 'fish'
     self.assertTrue(
         impact_task.get_impacts_from_url('123:456', 'job',
                                          'windows').is_empty())
     self.mock.get_start_and_end_revision.assert_has_calls(
         [mock.call('123:456', 'job')])
     self.mock.get_build_to_revision_mappings.assert_has_calls(
         [mock.call('windows')])
 def test_bail_out_no_build_to_revision_mapping(self):
     """Test bailing out when get_build_to_revision_mapping is empty"""
     self.mock.get_build_to_revision_mappings.return_value = None
     self.assertTrue(
         impact_task.get_impacts_from_url('123:456', 'job',
                                          'windows').is_empty())
     self.mock.get_start_and_end_revision.assert_has_calls(
         [mock.call('123:456', 'job')])
     self.mock.get_build_to_revision_mappings.assert_has_calls(
         [mock.call('windows')])
     self.mock.get_impact.assert_has_calls([])
示例#8
0
  def test_get_impacts(self):
    """Test getting impacts."""
    impacts = impact_task.get_impacts_from_url('123:456', 'job', 'windows')

    self.assertEqual('s', impacts.stable.version)
    self.assertFalse(impacts.stable.likely)
    self.assertEqual('b', impacts.beta.version)
    self.assertTrue(impacts.beta.likely)

    self.mock.get_start_and_end_revision.assert_has_calls(
        [mock.call('123:456', 'job')])
    self.mock.get_build_to_revision_mappings.assert_has_calls(
        [mock.call('windows')])
    self.mock.get_impact.assert_has_calls([
        mock.call('stable-version', 1, 100),
        mock.call('beta-version', 1, 100)
    ])
 def test_bail_if_two_identically_named_components(self):
     """Tests we bail if a comp is given twice in the component deps."""
     self.mock.get_build_to_revision_mappings.return_value = {
         'stable': {
             'revision': '398287',
             'version': '74.0.1345.34'
         },
         'beta': {
             'revision': '400000',
             'version': '76.0.1353.43'
         }
     }
     self.mock.get_component_name.return_value = 'skia'
     self.assertTrue(
         impact_task.get_impacts_from_url('123:456', 'job',
                                          'windows').is_empty())
     self.mock.get_start_and_end_revision.assert_has_calls(
         [mock.call('123:456', 'job')])
     self.mock.get_build_to_revision_mappings.assert_has_calls(
         [mock.call('windows')])
示例#10
0
    def test_get_impacts_known_component(self):
        """Test getting impacts for a known component."""
        self.mock.get_component_name.return_value = 'v8'
        impacts = impact_task.get_impacts_from_url('123:456', 'job', 'windows')

        self.assertEqual('s', impacts.stable.version)
        self.assertFalse(impacts.stable.likely)
        self.assertEqual('b', impacts.beta.version)
        self.assertTrue(impacts.beta.likely)

        self.mock.get_start_and_end_revision.assert_has_calls(
            [mock.call('123:456', 'job')])
        self.mock.get_build_to_revision_mappings.assert_has_calls(
            [mock.call('windows')])
        self.mock.get_impact.assert_has_calls([
            mock.call({
                'version': '74.0.1345.34',
                'revision': '666666'
            }, 1, 100),
            mock.call({
                'version': '75.0.1353.43',
                'revision': '777777'
            }, 1, 100)
        ])