Exemple #1
0
    def test_get_single_release_html_two_same_updates_same_month(self):
        """Test the HTML view with two updates of the same type from the same month."""
        create_update(self.db, ['bodhi-3.4.0-1.fc27'])
        create_update(self.db, ['rust-chan-0.3.1-1.fc27'])
        self.db.flush()

        res = self.app.get('/releases/f17', headers={'Accept': 'text/html'})

        self.assertEquals(res.content_type, 'text/html')
        self.assertIn('f17-updates-testing', res)
        # Since the updates are the same type and from the same month, we should see a count of 2 in
        # the graph data.
        graph_data = 'data : [\n                2,\n              ]'
        self.assertTrue(graph_data in res)
Exemple #2
0
    def test_multiple_builds(self):
        """
        Assert that a greenwave message updates the gating tests status of an update.
        """
        # Create an update with multiple builds
        with mock.patch(target='uuid.uuid4', return_value='multiplebuilds'):
            update = create_update(
                self.db,
                ['MultipleBuild1-1.0-1.fc17', 'MultipleBuild2-1.0-1.fc17'])
            update.type = models.UpdateType.bugfix
            update.severity = models.UpdateSeverity.medium
        self.db.flush()

        # Reference it in the incoming message
        self.sample_message.body[
            "subject_identifier"] = "MultipleBuild1-1.0-1.fc17"

        # Put bogus info in the message to make sure it does not get used
        self.sample_message.body["policies_satisfied"] = False
        self.sample_message.body["summary"] = "this should not be used"

        # before the greenwave consumer run the gating tests status is None
        assert update.test_gating_status is None

        with mock.patch('bodhi.server.models.util.greenwave_api_post'
                        ) as mock_greenwave:
            greenwave_response = {
                'policies_satisfied': True,
                'summary': "all tests have passed"
            }
            mock_greenwave.return_value = greenwave_response
            self.handler(self.sample_message)

        # After the consumer run the gating tests status was updated.
        assert update.test_gating_status == models.TestGatingStatus.passed
Exemple #3
0
    def create_update(self, build_nvrs, release_name=u'F17'):
        """
        Create and return an Update with the given iterable of build_nvrs. Each build_nvr should be
        a tuple of strings describing the name, version, and release for the build. For example,
        build_nvrs might look like this:

        ((u'bodhi', u'2.3.3', u'1.fc24'), (u'python-fedora-atomic-composer', u'2016.3', u'1.fc24'))

        You can optionally pass a release_name to select a different release than the default F17,
        but the release must already exist in the database.

        This is a convenience wrapper around bodhi.tests.server.create_update so that tests can just
        call self.create_update() and not have to pass self.db.
        """
        return create_update(self.db, build_nvrs, release_name)
Exemple #4
0
    def test_build_unassociated(self, warning):
        """A warning should be logged if the Bodhi Build object is not associated with an Update."""
        update = self.db.query(Update).one()
        update.date_pushed = None
        u = create_update(self.db, [u'TurboGears-1.0.2.2-4.fc17'])
        u.builds[0].update = None
        self.db.flush()

        # _fetch_updates() is called as part of UpdateInfoMetadata.__init__() so we'll just
        # instantiate one.
        md = UpdateInfoMetadata(update.release, update.request, self.db, self.temprepo,
                                close_shelf=False)

        warning.assert_called_once_with(
            'TurboGears-1.0.2.2-4.fc17 does not have a corresponding update')
        # Since the Build didn't have an Update, no Update should have been added to md.updates.
        self.assertEqual(md.updates, set([]))
Exemple #5
0
    def create_update(self, build_nvrs, release_name='F17'):
        """
        Create and return an Update with the given iterable of build_nvrs.

        Each build_nvr should be a tuple of strings describing the name, version, and release for
        the build. For example, build_nvrs might look like this:

        (('bodhi', '2.3.3', '1.fc24'), ('python-fedora-atomic-composer', '2016.3', '1.fc24'))

        You can optionally pass a release_name to select a different release than the default F17,
        but the release must already exist in the database.

        This is a convenience wrapper around bodhi.tests.server.create_update so that tests can just
        call self.create_update() and not have to pass self.db.

        Args:
            build_nvrs (iterable): An iterable of 3-tuples. Each 3-tuple is strings that express
                the name, version, and release of the desired build.
            release_name (basestring): The name of the release to associate with the new updates.
        Returns:
            bodhi.server.models.Update: The new update.
        """
        return create_update(self.db, build_nvrs, release_name)