def test_register_unregister_isregistered(self): wizard_pool._clear() self.assertEqual(len(wizard_pool._entries), 0) wizard_pool.register(self.page_wizard) # Now, try to register the same thing with self.assertRaises(AlreadyRegisteredException): wizard_pool.register(self.page_wizard) self.assertEqual(len(wizard_pool._entries), 1) self.assertTrue(wizard_pool.is_registered(self.page_wizard)) self.assertTrue(wizard_pool.unregister(self.page_wizard)) self.assertEqual(len(wizard_pool._entries), 0) # Now, try to unregister something that is not registered self.assertFalse(wizard_pool.unregister(self.user_settings_wizard))
def test_get_entries(self): """ Test that the registered entries are returned in weight-order, no matter which order they were added. """ wizard_pool._clear() wizard_pool.register(self.page_wizard) wizard_pool.register(self.user_settings_wizard) wizards = [self.page_wizard, self.user_settings_wizard] wizards = sorted(wizards, key=lambda e: getattr(e, 'weight')) entries = wizard_pool.get_entries() self.assertSequencesEqual(entries, wizards) wizard_pool._clear() wizard_pool.register(self.user_settings_wizard) wizard_pool.register(self.page_wizard) wizards = [self.page_wizard, self.user_settings_wizard] wizards = sorted(wizards, key=lambda e: getattr(e, 'weight')) entries = wizard_pool.get_entries() self.assertSequencesEqual(entries, wizards)
def test_get_entry(self): wizard_pool._clear() wizard_pool.register(self.page_wizard) entry = wizard_pool.get_entry(self.page_wizard) self.assertEqual(entry, self.page_wizard)