def test_export_with_dict(self): xml = """\ <registry> <record name="test.export.dict"> <field type="plone.registry.field.Dict"> <default /> <key_type type="plone.registry.field.ASCIILine"> <title>Key</title> </key_type> <title>Dict</title> <value_type type="plone.registry.field.Int"> <title>Value</title> </value_type> </field> <value> <element key="a">1</element> </value> </record> </registry>""" self.registry.records['test.export.dict'] = \ Record(field.Dict(title=u"Dict", default={}, key_type=field.ASCIILine(title=u"Key"), value_type=field.Int(title=u"Value")), value={'a': 1}) context = DummyExportContext(self.site) exportRegistry(context) self.assertEqual('registry.xml', context._wrote[0][0]) self.assertXmlEquals(xml, context._wrote[0][1])
def test_import_dict_nopurge(self): xml = """\ <registry> <record name="test.registry.field"> <value purge="false"> <element key="x">4</element> <element key="y">6</element> </value> </record> </registry> """ self.registry.records['test.registry.field'] = \ Record(field.Dict(title=u"Simple record", key_type=field.ASCIILine(title=u"Key"), value_type=field.Int(title=u"Val")), value={'a': 1}) context = DummyImportContext(self.site, purge=False) context._files = {'registry.xml': xml} importRegistry(context) self.assertEquals(1, len(self.registry.records)) self.failUnless( isinstance(self.registry.records['test.registry.field'].field, field.Dict)) self.assertEquals( u"Simple record", self.registry.records['test.registry.field'].field.title) self.assertEquals({ 'a': 1, 'x': 4, 'y': 6 }, self.registry['test.registry.field'])
def test_fieldref_interfaces(self): from plone.registry import field, FieldRef from plone.registry.interfaces import IFieldRef from zope.schema.interfaces import ICollection listField = field.List(value_type=field.ASCIILine()) ref = FieldRef('some.record', listField) self.assertTrue(ICollection.providedBy(ref)) self.assertTrue(IFieldRef.providedBy(ref))
def setFunctionForOperation(self, operation, function): function_field = field.ASCIILine(title=u"Operator") function_record = Record(function_field) function_record.value = function self.registry.records[operation] = function_record
def test_event_with_package_uninstalled(self): self.registry.records['foo'] = Record(field.ASCIILine(), 'foo') qi = self.portal['portal_quickinstaller'] qi.uninstallProducts(products=[PROJECTNAME]) # should not raise exceptions on changes self.registry['foo'] = 'bar'
def test_event_with_package_uninstalled(self): self.registry.records['foo'] = Record(field.ASCIILine(), 'foo') qi = get_installer(self.portal, self.request) qi.uninstall_product(PROJECTNAME) # should not raise exceptions on changes self.registry['foo'] = 'bar'