コード例 #1
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_exception_handler(self, exit, setup_logging, getLogger,
                               initialize_db, get_appsettings, get_session):
        """Test the exception handler."""
        log = getLogger.return_value
        koji = get_session.return_value
        release = models.Release.query.first()
        release.state = models.ReleaseState.pending
        update = models.Update.query.filter_by(release=release).first()
        update.date_stable = datetime.utcnow() - timedelta(days=2)
        update.status = models.UpdateStatus.stable
        # Since only the stable tag is not present, no calls to untagBuild should happen.
        koji.listTags.side_effect = IOError("Can't talk to koji bro")
        self.db.flush()

        untag_branched.main(['untag_branched', 'some_config_path'])

        setup_logging.assert_called_once_with()
        initialize_db.assert_called_once_with({'some': 'settings'})
        get_appsettings.assert_called_once_with('some_config_path')
        # Nothing should have been untagged
        assert koji.untagBuild.call_count == 0
        # An error should have been logged
        log.error.assert_called_once_with(koji.listTags.side_effect)
        koji.listTags.assert_called_once_with('bodhi-2.0-1.fc17')
        exit.assert_called_once_with(1)
コード例 #2
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_no_tags_to_remove(self, setup_logging, getLogger, initialize_db,
                               get_appsettings, get_session):
        """Assert correct behavior when there are no tags to remove."""
        log = getLogger.return_value
        koji = get_session.return_value
        release = models.Release.query.first()
        release.state = models.ReleaseState.pending
        update = models.Update.query.filter_by(release=release).first()
        update.date_stable = datetime.utcnow() - timedelta(days=2)
        update.status = models.UpdateStatus.stable
        # Since only the stable tag is not present, no calls to untagBuild should happen.
        koji.listTags.return_value = [{'name': 'f17'}]
        self.db.flush()

        untag_branched.main(['untag_branched', 'some_config_path'])

        setup_logging.assert_called_once_with()
        initialize_db.assert_called_once_with({'some': 'settings'})
        get_appsettings.assert_called_once_with('some_config_path')
        # Nothing should have been untagged
        assert koji.untagBuild.call_count == 0
        # No errors should have been logged
        assert log.error.call_count == 0
        # The Release name should have been logged
        log.info.assert_called_once_with(release.name)
        koji.listTags.assert_called_once_with('bodhi-2.0-1.fc17')
コード例 #3
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_testing_tag_present_update_too_new(self, setup_logging, getLogger,
                                                initialize_db, get_appsettings,
                                                get_session):
        """The testing tag should stay if update is too new."""
        log = getLogger.return_value
        koji = get_session.return_value
        release = models.Release.query.first()
        release.state = models.ReleaseState.pending
        update = models.Update.query.filter_by(release=release).first()
        update.date_stable = datetime.utcnow()
        update.status = models.UpdateStatus.stable
        # The testing tag is present and should stay.
        koji.listTags.return_value = [{
            'name': 'f17-updates-testing'
        }, {
            'name': 'f17'
        }]
        self.db.flush()

        untag_branched.main(['untag_branched', 'some_config_path'])

        setup_logging.assert_called_once_with()
        initialize_db.assert_called_once_with({'some': 'settings'})
        get_appsettings.assert_called_once_with('some_config_path')
        # Nothing should have been untagged
        assert koji.untagBuild.call_count == 0
        # No errors should have been logged
        assert log.error.call_count == 0
        # The Release name should have been logged
        log.info.assert_called_once_with(release.name)
        # There should have been no attempts to list the tags
        assert koji.listTags.call_count == 0
コード例 #4
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_testing_tag_present(self, setup_logging, getLogger, initialize_db,
                                 get_appsettings, get_session):
        """The testing tag should be removed if it is present."""
        log = getLogger.return_value
        koji = get_session.return_value
        release = models.Release.query.first()
        release.state = models.ReleaseState.pending
        update = models.Update.query.filter_by(release=release).first()
        update.date_stable = datetime.utcnow() - timedelta(days=2)
        update.status = models.UpdateStatus.stable
        # The testing tag is present so it should be removed.
        koji.listTags.return_value = [{
            'name': 'f17-updates-testing'
        }, {
            'name': 'f17'
        }]
        self.db.flush()

        untag_branched.main(['untag_branched', 'some_config_path'])

        setup_logging.assert_called_once_with()
        initialize_db.assert_called_once_with({'some': 'settings'})
        get_appsettings.assert_called_once_with('some_config_path')
        # Nothing should have been untagged
        koji.untagBuild.assert_called_once_with('f17-updates-testing',
                                                'bodhi-2.0-1.fc17')
        # An error should have been logged about the stable tag missing
        assert log.error.call_count == 0
        # The Release name should have been logged and a message should have been logged about
        # removing the tag.
        assert log.info.mock_calls == \
            [call(release.name), call('Removing f17-updates-testing from bodhi-2.0-1.fc17')]
        koji.listTags.assert_called_once_with('bodhi-2.0-1.fc17')
コード例 #5
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_stable_tag_missing(self, setup_logging, getLogger, initialize_db,
                                get_appsettings, get_session):
        """An error should be logged if the stable tag is not on a stable build."""
        log = getLogger.return_value
        koji = get_session.return_value
        release = models.Release.query.first()
        release.state = models.ReleaseState.pending
        update = models.Update.query.filter_by(release=release).first()
        update.date_stable = datetime.utcnow() - timedelta(days=2)
        update.status = models.UpdateStatus.stable
        # Since the stable tag is not present, none of these should be removed.
        koji.listTags.return_value = [{
            'name': 'f17-updates-testing'
        }, {
            'name': 'f17-updates-signing-pending'
        }, {
            'name': 'f17-updates-testing-pending'
        }]
        self.db.flush()

        untag_branched.main(['untag_branched', 'some_config_path'])

        setup_logging.assert_called_once_with()
        initialize_db.assert_called_once_with({'some': 'settings'})
        get_appsettings.assert_called_once_with('some_config_path')
        # Nothing should have been untagged
        assert koji.untagBuild.call_count == 0
        # An error should have been logged about the stable tag missing
        log.error.assert_called_once_with(
            ("bodhi-2.0-1.fc17 not tagged as stable ['f17-updates-testing', "
             "'f17-updates-signing-pending', 'f17-updates-testing-pending']"))
        # The Release name should have been logged
        log.info.assert_called_once_with(release.name)
        koji.listTags.assert_called_once_with('bodhi-2.0-1.fc17')
コード例 #6
0
    def test_usage(self, stdout, exit):
        """Ensure that usage is called if not enough args are passed."""
        exit.side_effect = RuntimeError("We don't want the main() function to continue.")

        with self.assertRaises(RuntimeError) as exc:
            untag_branched.main(['untag_branched'])

        self.assertIs(exc.exception, exit.side_effect)
        self.assertEqual(
            stdout.getvalue(),
            'usage: untag_branched <config_uri>\n(example: "untag_branched development.ini")\n')
        exit.assert_called_once_with(1)
コード例 #7
0
ファイル: test_untag_branched.py プロジェクト: sitedata/bodhi
    def test_usage(self, stdout, exit):
        """Ensure that usage is called if not enough args are passed."""
        exit.side_effect = RuntimeError(
            "We don't want the main() function to continue.")

        with pytest.raises(RuntimeError) as exc:
            untag_branched.main(['untag_branched'])

        assert exc.type is RuntimeError
        assert exc.value is exit.side_effect
        assert stdout.getvalue() == \
            'usage: untag_branched <config_uri>\n(example: "untag_branched development.ini")\n'
        exit.assert_called_once_with(1)