Exemple #1
0
    def test_encoding(self):
        """Ensure that the UnicodeDecode is properly handled."""
        u = models.Update.query.first()
        u.alias = '\xe7'

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        self.assertIn('\xe7', t)
Exemple #2
0
    def test_changelog_single_entry(self, get_latest):
        """Test that we handle a changelog with a single entry correctly."""
        get_latest.return_value = 'TurboGears-1.9.1-42.fc17'
        u = self.create_update(['TurboGears-2.0.0.0-1.fc17'])

        # This should not blow up like it did in https://github.com/fedora-infra/bodhi/issues/2768
        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        assert 'ChangeLog:' in t
        assert '* Sat Aug  3 2013 Randy Barlow <[email protected]> - 2.2.0-1' in t
        assert '- Added some bowlofeggs charm.' in t
Exemple #3
0
    def test_stable_update(self):
        """Stable updates should not include --enablerepo=updates-testing in the notice."""
        u = models.Update.query.first()
        u.status = models.UpdateStatus.stable

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        self.assertFalse('--enablerepo=updates-testing' in t)
        self.assertFalse('Fedora Test Update Notification' in t)
        # The advisory flag should be included in the dnf instructions.
        self.assertTrue('dnf upgrade --advisory {}'.format(u.alias) in t)
Exemple #4
0
    def test_testing_update(self):
        """Testing updates should include --enablerepo=updates-testing in the notice."""
        u = models.Update.query.first()
        u.status = models.UpdateStatus.testing

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([line for line in t[0]])
        assert '--enablerepo=updates-testing' in t
        assert 'Fedora Test Update Notification' in t
        # The advisory flag should be included in the dnf instructions.
        assert 'dnf --enablerepo=updates-testing upgrade --advisory {}'.format(
            u.alias) in t
Exemple #5
0
    def add_to_digest(self, update):
        """Add an package to the digest dictionary.

        {'release-id': {'build nvr': body text for build, ...}}

        Args:
            update (bodhi.server.models.Update): The update to add to the dict.
        """
        prefix = update.release.long_name
        if prefix not in self.testing_digest:
            self.testing_digest[prefix] = {}
        for i, subbody in enumerate(mail.get_template(
                update, use_template='maillist_template')):
            self.testing_digest[prefix][update.builds[i].nvr] = subbody[1]
Exemple #6
0
    def test_changelog(self):
        """Ensure that a changelog gets generated when there is an older Build."""
        u = self.create_update(['TurboGears-2.0.0.0-1.fc17'])

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        self.assertTrue('ChangeLog:' in t)
        self.assertTrue('* Sat Aug  3 2013 Randy Barlow <[email protected]> - 2.2.0-1' in t)
        self.assertTrue('- Added some bowlofeggs charm.' in t)
        # Only the new bits of the changelog should be included in the notice, so this should not
        # appear even though it is in the package's changelog.
        self.assertFalse('* Tue Jul 10 2012 Paul Moore <*****@*****.**> - 0.1.0-1' in t)
        self.assertFalse('- Limit package to x86/x86_64 platforms (RHBZ #837888)' in t)
Exemple #7
0
    def test_module_build(self):
        """ModuleBuilds don't have get_latest(), so lets verify that this is OK."""
        release = self.create_release('27M')
        build = models.ModuleBuild(
            nvr='testmodule:master:1', release=release,
            package=models.Package(name='testmodule', type=models.ContentType.module))
        update = models.Update(builds=[build], release=release)

        # This should not raise an Exception.
        t = mail.get_template(update)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        # No changelog should appear. We can just verify that there's a blank line where the
        # changelog would be.
        self.assertTrue('----\n\nThis update can be installed' in t)
Exemple #8
0
    def test_changelog_no_old_text(self, get_latest):
        """Ensure that a changelog gets generated when there is an older Build with no text."""
        get_latest.return_value = 'TurboGears-1.9.1-1.fc17'
        u = self.create_update(['TurboGears-2.0.0.0-1.fc17'])

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        self.assertTrue('ChangeLog:' in t)
        self.assertTrue('* Sat Aug  3 2013 Randy Barlow <[email protected]> - 2.2.0-1' in t)
        self.assertTrue('- Added some bowlofeggs charm.' in t)
        # Since we faked the 1.9.1-1 release as having [] as changelogtext in Koji, the entire
        # package changelog should have been included. We'll just spot check it here.
        self.assertTrue('* Tue Jul 10 2012 Paul Moore <*****@*****.**> - 0.1.0-1' in t)
        self.assertTrue('- Limit package to x86/x86_64 platforms (RHBZ #837888)' in t)
Exemple #9
0
    def test_changelog_single_entry(self, get_latest):
        """Test that we handle a changelog with a single entry correctly."""
        get_latest.return_value = 'TurboGears-1.9.1-42.fc17'
        u = self.create_update(['TurboGears-2.0.0.0-1.fc17'])

        # This should not blow up like it did in https://github.com/fedora-infra/bodhi/issues/2768
        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([line for line in t[0]])
        assert 'ChangeLog:' in t
        assert '* Sat Aug  3 2013 Randy Barlow <[email protected]> - 2.2.0-1' in t
        assert '- Added some bowlofeggs charm.' in t
        # Only the new bits of the changelog should be included in the notice, so this should not
        # appear even though it is in the package's changelog.
        assert '* Tue Jul 10 2012 Paul Moore <*****@*****.**> - 0.1.0-1' not in t
        assert '- Limit package to x86/x86_64 platforms (RHBZ #837888)' not in t
Exemple #10
0
    def test_skip_tracker_bug(self, debug):
        """Tracker security bugs should get skipped."""
        u = models.Update.query.first()
        u.type = models.UpdateType.security
        b = u.bugs[0]
        b.parent = False
        b.title = 'this should not appear'
        u.bugs.append(models.Bug(bug_id=54321, parent=True, title='this should appear'))

        t = mail.get_template(u)

        # Assemble the template for easier asserting.
        t = '\n'.join([l for l in t[0]])
        self.assertTrue('54321 - this should appear' in t)
        self.assertFalse('this should not appear' in t)
        self.assertEqual(debug.call_count, 1)
        self.assertIn('Skipping tracker bug', debug.mock_calls[0][1][0])
        self.assertIn('12345', debug.mock_calls[0][1][0])
        self.assertIn('this should not appear', debug.mock_calls[0][1][0])