class ZPTFieldTest(PloneTestCase.PloneTestCase): def afterSetUp(self): from Products.TemplateFields import ZPTField self.field = ZPTField('aField') self.folder.validate_field = lambda *args, **kw: None self.folder.setTitle("My Folder") def validate(self, value): errors = {} res = self.field.validate(value, self.folder, errors) return res, errors def test_defaults(self): self.assertEquals(self.field.get(self.folder), "My Folder\n") def test_getRaw(self): raw = self.field.getRaw(self.folder) self.assertEquals(raw, '<span tal:replace="here/title_or_id" />') def test_set(self): self.assertEquals(self.field.get(self.folder), "My Folder\n") self.field.set(self.folder, '<span tal:replace="here/aq_parent/title_or_id" />') self.assertEquals(self.field.get(self.folder), "Members\n") def test_set_zpt(self): # Just make sure setting PageTemplate works too. default_zpt = self.field.getDefault(self.folder) self.field.set(self.folder, default_zpt) self.assertEquals( self.field.getRaw(self.folder), default_zpt.read())