def setUp(self): self.portal_type = SiteTypes() #if not self.portal_type.get_registered(): self.portal_type.registry(ItemModel, ItemType)
class CMSPortalTypeTest(TestCase): def setUp(self): self.portal_type = SiteTypes() #if not self.portal_type.get_registered(): self.portal_type.registry(ItemModel, ItemType) def test_register_portal_type(self): self.assertTrue(isinstance(ItemTemplate, PortalTemplateBase)) self.assertTrue(isinstance(ItemType, PortalTypeBase)) self.assertEqual(ItemType.name,'item') def raise1(): self.portal_type.registry(ItemModel, Dummy) self.assertRaises(ImproperlyConfigured, raise1) self.assertTrue(self.portal_type.get_portal_type(ItemModel) is ItemType) self.assertEqual(self.portal_type.get_portal_type(ItemModel).name, 'item') self.assertTrue(('item model', 'Item') in self.portal_type.get_registered()) def raise2(): self.portal_type.registry(ItemModel, ItemType) self.assertRaises(AlreadyRegistered, raise2) def raise3(): self.portal_type.unregistry(ItemType) self.assertRaises(ImproperlyConfigured, raise3) self.portal_type.unregistry(ItemModel) def raise4(): self.portal_type.unregistry(ItemModel) self.assertRaises(NotRegistered, raise4) def _portal_type_templates(self): portal_type = ItemModel.portal_type self.assertTrue(len(portal_type.templates) == 1 ) self.assertTrue(ItemTemplate in portal_type.templates) self.assertTrue(portal_type.default_template is ItemTemplate) template = portal_type.default_template self.assertEqual(template.name, 'item')