def test_transaction_note_is_updated(self):
        note = TransactionNote()
        note.add_upgrade('my.package:default', ('1','1'), 'Migrate objects')
        note.add_upgrade('my.package:default', ('1702',), 'Remove utility')

        self.assertEquals(
            u'my.package:default -> 1.1 (Migrate objects)\n'
            u'my.package:default -> 1702 (Remove utility)',
            transaction.get().description)
    def test_cropped_according_to_already_existing_notes(self):
        # When the transaction note has already the maximum length
        # we cannot add anymore infos..
        profileid = 'my.package:default'
        transaction.get().note('.' * 65533)

        TransactionNote().add_upgrade(profileid, ('1000',), '')
        TransactionNote().set_transaction_note()

        self.assertLess(
            len(transaction.get().description), 65535,
            'Transaction note is too long, should be less than 65535')
    def test_transaction_note_is_updated(self):
        note = TransactionNote()
        note.add_upgrade('my.package:default', ('1','1'), 'Migrate objects')
        note.add_upgrade('my.package:default', ('1702',), 'Remove utility')
        note.set_transaction_note()

        self.assertEquals(
            u'my.package:default -> 1.1 (Migrate objects)\n'
            u'my.package:default -> 1702 (Remove utility)',
            transaction.get().description)
    def test_description_is_removed_when_note_gets_too_long(self):
        # Transaction note size is limited to 65533 characters
        description = 'A' * (65533 / 2)

        note = TransactionNote()
        note.add_upgrade('my.package:default', ('1000',), description)
        note.add_upgrade('my.package:default', ('1001',), description)

        # Prevent from printing the very long description in the assertion
        # message by not using assertIn..
        assert 'AAAA' not in transaction.get().description, \
            'Description seems not to be removed from too long' + \
            ' transaction note.'

        self.assertEquals(
            u'my.package:default -> 1000\n'
            u'my.package:default -> 1001',
            transaction.get().description)
Esempio n. 5
0
    def install(self, data):
        self._register_after_commit_hook()
        for profileid, upgradeids in data:
            self._upgrade_profile(profileid, upgradeids)

        for adapter in self._get_sorted_post_upgrade_adapters():
            adapter()

        TransactionNote().set_transaction_note()
        recook_resources()
        self._process_indexing_queue()
    def test_cropped_when_too_long_even_without_description(self):
        profileid = 'my.package:default'

        note = TransactionNote()
        for destination in range(1, (65533 / len(profileid)) + 2):
            note.add_upgrade(profileid, (str(destination),), '')

        note = transaction.get().description

        expected_start = 'my.package:default -> 1\n'
        self.assertTrue(
            note.startswith(expected_start),
            ('Expected transaction note to start with "%s",'
             ' but it started with "%s"') % (
                expected_start, note[:50]))

        self.assertTrue(
            note.endswith('...'),
            'Expected transaction note to be cropped, ending with "..." '
            'but it ends with "%s"' % note[-30:])
Esempio n. 7
0
    def install(self, data, intermediate_commit=False):
        self._register_after_commit_hook()
        for profileid, upgradeids in data:
            self._upgrade_profile(profileid, upgradeids, intermediate_commit)

        for adapter in self._get_sorted_post_upgrade_adapters():
            adapter()

        if intermediate_commit:
            transaction.get().note('finalizing installing upgrades')

        TransactionNote().set_transaction_note()
        recook_resources()
        self._process_indexing_queue()
Esempio n. 8
0
    def _upgrade_profile(self, profileid, upgradeids, intermediate_commit):
        last_dest_version = None

        for upgradeid in upgradeids:
            last_dest_version = self._do_upgrade(profileid, upgradeid) \
                or last_dest_version
            self._set_portal_setup_version(profileid, last_dest_version)

            if intermediate_commit:
                TransactionNote().set_transaction_note()
                self._process_indexing_queue()
                transaction.commit()
                self._register_after_commit_hook()

        self._set_quickinstaller_version(profileid)
Esempio n. 9
0
    def _do_upgrade(self, profileid, upgradeid):
        start = time.time()

        step = _upgrade_registry.getUpgradeStep(profileid, upgradeid)
        logger.log(logging.INFO, '_' * 70)
        logger.log(logging.INFO,
                   'UPGRADE STEP %s: %s' % (profileid, step.title))

        step.doStep(self.portal_setup)
        TransactionNote().add_upgrade(profileid, step.dest, step.title)

        msg = "Ran upgrade step %s for profile %s" % (step.title, profileid)
        logger.log(logging.INFO, msg)

        logger.log(
            logging.INFO,
            'Upgrade step duration: %s' % format_duration(time.time() - start))

        return step.dest
    def test_description_is_removed_when_note_gets_too_long(self):
        # Transaction note size is limited to 65535 characters
        description = 'A' * (65535 / 2)

        note = TransactionNote()
        note.add_upgrade('my.package:default', ('1000',), description)
        note.add_upgrade('my.package:default', ('1001',), description)
        note.set_transaction_note()

        # Prevent from printing the very long description in the assertion
        # message by not using assertIn..
        assert 'AAAA' not in transaction.get().description, \
            'Description seems not to be removed from too long' + \
            ' transaction note.'

        self.assertEquals(
            u'my.package:default -> 1000\n'
            u'my.package:default -> 1001',
            transaction.get().description)
Esempio n. 11
0
    def test_cropped_when_too_long_even_without_description(self):
        profileid = 'my.package:default'

        transaction.get().note('Some notes..')

        note = TransactionNote()
        for destination in range(1, (65535 // len(profileid)) + 2):
            note.add_upgrade(profileid, (str(destination), ), '')
        note.set_transaction_note()

        result = transaction.get().description
        expected_start = 'Some notes..\nmy.package:default -> 1\n'
        self.assertTrue(result.startswith(expected_start),
                        ('Expected transaction note to start with "%s",'
                         ' but it started with "%s"') %
                        (expected_start, result[:50]))

        self.assertTrue(
            result.endswith('...'),
            'Expected transaction note to be cropped, ending with "..." '
            'but it ends with "%s"' % result[-30:])