def test_single_minute_is_singular(self): self.assertEqual(['1 minute', '1 minute, 1 second', '1 minute, 2 seconds'], [format_duration(60), format_duration(60 + 1), format_duration(60 + 2)])
def test_floating_point_seconds_are_ceiled(self): self.assertEqual(['1 second', '1 second', '2 seconds', '2 seconds'], [format_duration(0.1), format_duration(0.9), format_duration(1.1), format_duration(1.9)])
def test_multiple_hours_is_plural(self): self.assertEqual(['2 hours', '2 hours, 1 minute', '2 hours, 2 minutes, 1 second', '2 hours, 2 minutes, 2 seconds'], [format_duration((2 * 60 * 60)), format_duration((2 * 60 * 60) + 60), format_duration((2 * 60 * 60) + (2 * 60) + 1), format_duration((2 * 60 * 60) + (2 * 60) + 2)])
def test_single_hour_is_singular(self): self.assertEqual(['1 hour', '1 hour, 1 minute', '1 hour, 2 minutes, 1 second', '1 hour, 2 minutes, 2 seconds'], [format_duration((60 * 60)), format_duration((60 * 60) + 60), format_duration((60 * 60) + (2 * 60) + 1), format_duration((60 * 60) + (2 * 60) + 2)])
def install(self): """Installs the selected upgrades. """ start = time.time() gstool = getToolByName(self.context, 'portal_setup') executioner = getAdapter(gstool, IExecutioner) data = self._get_upgrades_to_install() executioner.install(data) logging.getLogger('ftw.upgrade').info('FINISHED') logging.getLogger('ftw.upgrade').info( 'Duration for all selected upgrade steps: %s' % ( format_duration(time.time() - start)))
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_multiple_minutes_is_plural(self): self.assertEqual(['2 minutes, 1 second', '2 minutes, 2 seconds'], [format_duration((2 * 60) + 1), format_duration((2 * 60) + 2)])
def test_multiple_seconds_is_plural(self): self.assertEqual('2 seconds', format_duration(2))
def test_single_second_is_singular(self): self.assertEqual('1 second', format_duration(1))
def test_zero_seconds_is_supported(self): self.assertEqual('0 seconds', format_duration(0))
def test_multiple_minutes_is_plural(self): self.assertEqual( ['2 minutes, 1 second', '2 minutes, 2 seconds'], [format_duration((2 * 60) + 1), format_duration((2 * 60) + 2)])