Exemplo n.º 1
0
    def test_clear_all_caches(self):

        class ISchema1(Interface):
            pass

        fti1 = DexterityFTI(u"testtype")
        fti1.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti1, IDexterityFTI, name=u"testtype1")

        fti2 = DexterityFTI(u"testtype")
        fti2.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti2, IDexterityFTI, name=u"testtype2")

        # reset schemacache counter
        SCHEMA_CACHE.invalidations = 0

        # fill cache should call lookupschema one time
        schema1 = SCHEMA_CACHE.get(u"testtype1")
        schema2 = SCHEMA_CACHE.get(u"testtype2")
        self.assertTrue(schema1 is schema2 is ISchema1)

        # clear
        SCHEMA_CACHE.clear()

        self.assertEqual(SCHEMA_CACHE.invalidations, 2)

        # check invalidations

        # fill cache again should call lookupschema one time
        schema1 = SCHEMA_CACHE.get(u"testtype1")
        schema2 = SCHEMA_CACHE.get(u"testtype2")
        self.assertTrue(schema1 is schema2 is ISchema1)
Exemplo n.º 2
0
    def test_clear_all_caches(self):

        class ISchema1(Interface):
            pass

        fti1 = DexterityFTI(u"testtype")
        fti1.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti1, IDexterityFTI, name=u"testtype1")

        fti2 = DexterityFTI(u"testtype")
        fti2.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti2, IDexterityFTI, name=u"testtype2")

        # reset schemacache counter
        SCHEMA_CACHE.invalidations = 0

        # fill cache should call lookupschema one time
        schema1 = SCHEMA_CACHE.get(u"testtype1")
        schema2 = SCHEMA_CACHE.get(u"testtype2")
        self.assertTrue(schema1 is schema2 is ISchema1)

        # clear
        SCHEMA_CACHE.clear()

        self.assertEqual(SCHEMA_CACHE.invalidations, 2)

        # check invalidations

        # fill cache again should call lookupschema one time
        schema1 = SCHEMA_CACHE.get(u"testtype1")
        schema2 = SCHEMA_CACHE.get(u"testtype2")
        self.assertTrue(schema1 is schema2 is ISchema1)
Exemplo n.º 3
0
    def setUp(self):
        super(TestBaseBehavior, self).setUp()

        fti = DexterityFTI('OpenGeverBaseFTI')
        fti.schema = 'opengever.base.tests.emptyschema.IEmptySchema'
        fti.behaviors = ('opengever.base.behaviors.base.IOpenGeverBase',)
        self.portal.portal_types._setObject('OpenGeverBaseFTI', fti)
        fti.lookupSchema()
        transaction.commit()
    def setUp(self):
        super(TestCreatorBehavior, self).setUp()
        self.grant('Contributor')

        fti = DexterityFTI('ReferenceFTI')
        fti.behaviors = ('opengever.base.behaviors.creator.ICreator', )
        self.portal.portal_types._setObject('ReferenceFTI', fti)
        fti.lookupSchema()
        transaction.commit()
Exemplo n.º 5
0
 def _setup_test_content_type(self, name):
     from plone.dexterity.fti import DexterityFTI
     fti = DexterityFTI(name)
     fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IDublinCore',
                      'adhocracy.plone.behavior.IAdhocracyStaticPagesRoot')
     fti.klass = 'plone.dexterity.content.Container'
     fti.filter_content_types = False
     self.portal.portal_types._setObject(name, fti)
     fti.lookupSchema()
Exemplo n.º 6
0
    def setUpPloneSite(self, portal):
        applyProfile(portal, 'plone.app.dexterity:default')
        applyProfile(portal, 'ftw.solr:default')

        fti = DexterityFTI('DexterityFolder',
                           klass="plone.dexterity.content.Container",
                           global_allow=True)
        portal.portal_types._setObject('ClassificationFTI', fti)
        fti.lookupSchema()
    def setUp(self):
        super(TestCreatorBehavior, self).setUp()
        self.grant('Contributor')

        fti = DexterityFTI('ReferenceFTI')
        fti.behaviors = ('opengever.base.behaviors.creator.ICreator',)
        self.portal.portal_types._setObject('ReferenceFTI', fti)
        fti.lookupSchema()
        transaction.commit()
Exemplo n.º 8
0
    def setUpPloneSite(self, portal):
        applyProfile(portal, 'plone.app.dexterity:default')
        applyProfile(portal, 'ftw.solr:default')

        fti = DexterityFTI('DexterityFolder',
                           klass="plone.dexterity.content.Container",
                           global_allow=True)
        portal.portal_types._setObject('ClassificationFTI', fti)
        fti.lookupSchema()
    def setUp(self):
        super(TestBaseBehavior, self).setUp()

        fti = DexterityFTI('OpenGeverBaseFTI')
        fti.schema = 'opengever.base.tests.emptyschema.IEmptySchema'
        fti.behaviors = ('opengever.base.behaviors.base.IOpenGeverBase', )
        self.portal.portal_types._setObject('OpenGeverBaseFTI', fti)
        fti.lookupSchema()
        transaction.commit()
Exemplo n.º 10
0
    def setUp(self):
        super(TestBaseBehavior, self).setUp()
        self.grant("Contributor")

        fti = DexterityFTI("OpenGeverBaseFTI")
        fti.schema = "opengever.base.tests.emptyschema.IEmptySchema"
        fti.behaviors = ("opengever.base.behaviors.base.IOpenGeverBase",)
        self.portal.portal_types._setObject("OpenGeverBaseFTI", fti)
        fti.lookupSchema()
        transaction.commit()
Exemplo n.º 11
0
    def setUp(self):
        super(TestClassificationBehavior, self).setUp()
        self.grant('Contributor')

        fti = DexterityFTI('ClassificationFTI',
                           klass="plone.dexterity.content.Container",
                           global_allow=True,
                           filter_content_types=False)
        fti.behaviors = ('opengever.base.behaviors.classification.IClassification',)
        self.portal.portal_types._setObject('ClassificationFTI', fti)
        fti.lookupSchema()
        transaction.commit()
Exemplo n.º 12
0
    def test_no_tagged_value(self):

        # Mock schema model
        class ITestSchema(Interface):
            test = zope.schema.TextLine(title=u"Test")

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ITestSchema)
        fti_mock.behaviors = ()
        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        SCHEMA_CACHE.clear()

        # Everything allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))

        # Unknown attributes are allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__(
                'random', u"stuff"))
Exemplo n.º 13
0
    def test_schema_exception(self):

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(side_effect=AttributeError)
        fti_mock.behaviors = ()

        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        SCHEMA_CACHE.clear()

        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
        )
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
        )
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
        )
Exemplo n.º 14
0
    def test_no_tagged_value(self):

        # Mock schema model
        class ITestSchema(Interface):
            test = zope.schema.TextLine(title=u"Test")

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ITestSchema)
        fti_mock.behaviors = ()
        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        SCHEMA_CACHE.clear()

        # Everything allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
        )
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
        )

        # Unknown attributes are allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
        )
Exemplo n.º 15
0
    def test_getSize(self):
        class SizedValue(str):
            def getSize(self):
                return len(self)

        class ITest(Interface):
            field1 = zope.schema.TextLine()

        class ITestBehavior(Interface):
            field2 = zope.schema.TextLine()

        alsoProvides(ITestBehavior, IFormFieldProvider)

        self.mock_adapter(DexterityBehaviorAssignable, IBehaviorAssignable,
                          (IDexterityContent, ))

        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = ['test_behavior']
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        behavior_reg = BehaviorRegistration(u"Test Behavior", "",
                                            ITestBehavior, ITestBehavior, None)
        self.mock_utility(behavior_reg, IBehavior, name="test_behavior")

        item = Item('item')
        item.portal_type = 'testtype'
        item.field1 = SizedValue('1')
        item.field2 = SizedValue('22')

        self.assertEqual(3, item.getSize())
Exemplo n.º 16
0
    def test_update_ignores_type_check_if_security_check_deferred(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype',
                                         allowedContentTypes=lambda: [])
        request_mock = TestRequest()
        alsoProvides(request_mock, IDeferSecurityCheck)

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(FieldWidgets, IWidgets,
                          (Interface, Interface, Interface))

        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # Form
        view = DefaultAddForm(context_mock, request_mock)
        view.portal_type = fti_mock.getId()
        try:
            view.update()
        except ValueError:
            self.fail("Update raised Unauthorized with security checks "
                      "deferred")
Exemplo n.º 17
0
    def test_update_checks_allowed_types(self):

        # Context and request
        context_mock = self.create_dummy(
            portal_type=u'testtype',
            allowedContentTypes=lambda: [])
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(
            FieldWidgets,
            IWidgets,
            (Interface, Interface, Interface)
        )

        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # Form
        view = DefaultAddForm(context_mock, request_mock)
        view.portal_type = fti_mock.getId()
        self.assertRaises(ValueError, view.update)
Exemplo n.º 18
0
    def test_update_ignores_type_check_if_security_check_deferred(self):

        # Context and request
        context_mock = self.create_dummy(
            portal_type=u'testtype',
            allowedContentTypes=lambda: [])
        request_mock = TestRequest()
        alsoProvides(request_mock, IDeferSecurityCheck)

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(
            FieldWidgets,
            IWidgets,
            (Interface, Interface, Interface)
        )

        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # Form
        view = DefaultAddForm(context_mock, request_mock)
        view.portal_type = fti_mock.getId()
        try:
            view.update()
        except ValueError:
            self.fail("Update raised Unauthorized with security checks "
                      "deferred")
Exemplo n.º 19
0
    def test_fires_edit_begun_event(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype')
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(
            FieldWidgets,
            IWidgets,
            (Interface, Interface, Interface)
        )
        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # mock notify
        from zope.event import notify
        notify_mock = self.patch_global(notify)

        # Form
        view = DefaultEditForm(context_mock, request_mock)
        view.update()

        self.assertTrue(notify_mock.called)
        self.assertTrue(
            IEditBegunEvent.providedBy(notify_mock.call_args[0][0]))
Exemplo n.º 20
0
    def test_fires_edit_begun_event(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype')
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(FieldWidgets, IWidgets,
                          (Interface, Interface, Interface))
        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # mock notify
        from zope.event import notify
        notify_mock = self.patch_global(notify)

        # Form
        view = DefaultEditForm(context_mock, request_mock)
        view.update()

        self.assertTrue(notify_mock.called)
        self.assertTrue(IEditBegunEvent.providedBy(
            notify_mock.call_args[0][0]))
Exemplo n.º 21
0
    def test_schema_lookup_default_view(self):

        # Context and request
        class IMarker(IDexterityContent):
            pass

        context_mock = self.create_dummy(portal_type=u'testtype')
        alsoProvides(context_mock, IMarker)
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        fti_mock.behaviors = (IBehaviorOne.__identifier__,
                              IBehaviorTwo.__identifier__,
                              IBehaviorThree.__identifier__)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        from plone.behavior.interfaces import IBehavior
        from plone.behavior.registration import BehaviorRegistration
        registration = BehaviorRegistration(
            title=u"Test Behavior 1",
            description=u"Provides test behavior",
            interface=IBehaviorOne,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior, IBehaviorOne.__identifier__)
        registration = BehaviorRegistration(
            title=u"Test Behavior 2",
            description=u"Provides test behavior",
            interface=IBehaviorTwo,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior, IBehaviorTwo.__identifier__)
        registration = BehaviorRegistration(
            title=u"Test Behavior 3",
            description=u"Provides test behavior",
            interface=IBehaviorThree,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior,
                          IBehaviorThree.__identifier__)

        # Form
        view = DefaultView(context_mock, request_mock)
        view.portal_type = u"testtype"

        self.assertEqual(ISchema, view.schema)

        # we expect here only formfieldprovider!
        self.assertEqual((IBehaviorOne, IBehaviorTwo),
                         tuple(view.additionalSchemata))

        # When we register our own IBehaviorAssignable we can
        # influence what goes into the additionalSchemata.
        self.mock_adapter(NoBehaviorAssignable, IBehaviorAssignable, [IMarker])
        additionalSchemata = tuple(view.additionalSchemata)
        self.assertEqual(tuple(), tuple(additionalSchemata))
Exemplo n.º 22
0
    def test_schema_lookup_add(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype')
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        fti_mock.behaviors = (IBehaviorOne.__identifier__,
                              IBehaviorTwo.__identifier__,
                              IBehaviorThree.__identifier__)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        from plone.behavior.interfaces import IBehavior
        from plone.behavior.registration import BehaviorRegistration
        registration = BehaviorRegistration(
            title=u"Test Behavior 1",
            description=u"Provides test behavior",
            interface=IBehaviorOne,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior, IBehaviorOne.__identifier__)
        registration = BehaviorRegistration(
            title=u"Test Behavior 2",
            description=u"Provides test behavior",
            interface=IBehaviorTwo,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior, IBehaviorTwo.__identifier__)
        registration = BehaviorRegistration(
            title=u"Test Behavior 3",
            description=u"Provides test behavior",
            interface=IBehaviorThree,
            marker=None,
            factory=None)
        self.mock_utility(registration, IBehavior,
                          IBehaviorThree.__identifier__)

        # Form
        view = DefaultAddForm(context_mock, request_mock)
        view.portal_type = u"testtype"

        self.assertEqual(ISchema, view.schema)

        # we expect here only formfieldprovider!
        self.assertEqual((IBehaviorOne, IBehaviorTwo),
                         tuple(view.additionalSchemata))

        # When we register our own IBehaviorAssignable we can
        # influence what goes into the additionalSchemata. But in an Addform
        # this never grips, since its an adapter on context, and contextless
        # there is always the FTI the only valid source
        self.mock_adapter(NoBehaviorAssignable, IBehaviorAssignable,
                          [Interface])
        self.assertEqual((IBehaviorOne, IBehaviorTwo),
                         tuple(view.additionalSchemata))
Exemplo n.º 23
0
 def test_lookupSchema_with_nonexistant_schema(self):
     ''' Tests the case where a dexterity type is not removed cleanly
     from the fti, but the code has been removed.
     '''
     fti = DexterityFTI('testtype')
     fti.schema = 'model.wont.be.imported'
     portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
     self.mock_utility(portal, Interface)
     schemaName = utils.portalTypeToSchemaName(fti.getId())
     setattr(plone.dexterity.schema.generated, schemaName, ITestSchema)
     self.assertEqual(ITestSchema, fti.lookupSchema())
     delattr(plone.dexterity.schema.generated, schemaName)
Exemplo n.º 24
0
    def setUp(self):
        self.portal = self.layer['portal']
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        login(self.portal, TEST_USER_NAME)

        # Because we have a bug if we use ftw.geo in combination
        # with the IReferenceable behavior, we run all tests with
        # this behavior.
        fti = DexterityFTI(
            u'Address',
            schema='.'.join((IAddressSchema.__module__, 'IAddressSchema')),
            klass='.'.join((Address.__module__, 'Address')))

        self.portal.portal_types._setObject('Address', fti)
        fti.lookupSchema()

        getSiteManager().registerAdapter(factory=AddressLocationAdapter,
                                         required=[IAddress],
                                         provided=IGeocodableLocation)

        transaction.commit()
Exemplo n.º 25
0
 def test_lookupSchema_with_nonexistant_schema(self):
     """ Tests the case where a dexterity type is not removed cleanly
     from the fti, but the code has been removed.
     """
     fti = DexterityFTI(u"testtype")
     fti.schema = 'model.wont.be.imported'
     portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
     self.mock_utility(portal, ISiteRoot)
     schemaName = utils.portalTypeToSchemaName(fti.getId())
     setattr(plone.dexterity.schema.generated, schemaName, ITestSchema)
     self.assertEqual(ITestSchema, fti.lookupSchema())
     delattr(plone.dexterity.schema.generated, schemaName)
Exemplo n.º 26
0
    def test_repeated_get_lookup(self):
        class ISchema(Interface):
            pass

        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"testtype")
        schema2 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is schema2 is ISchema)
Exemplo n.º 27
0
    def test_repeated_get_lookup(self):

        class ISchema(Interface):
            pass

        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"testtype")
        schema2 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is schema2 is ISchema)
Exemplo n.º 28
0
    def test_lookupSchema_with_dynamic_schema(self):
        fti = DexterityFTI('testtype')
        fti.schema = None  # use dynamic schema

        portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
        self.mock_utility(portal, Interface)

        schemaName = utils.portalTypeToSchemaName(fti.getId())
        setattr(plone.dexterity.schema.generated, schemaName, ITestSchema)

        self.assertEqual(ITestSchema, fti.lookupSchema())

        # cleanup
        delattr(plone.dexterity.schema.generated, schemaName)
Exemplo n.º 29
0
    def test_unknown_type_not_cached(self):
        class ISchema1(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"othertype")
        schema2 = SCHEMA_CACHE.get(u"testtype")
        schema3 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is None)
        self.assertTrue(schema2 is schema3 is ISchema1)
Exemplo n.º 30
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        login(self.portal, TEST_USER_NAME)

        portal_types = getToolByName(self.portal, 'portal_types')

        fti = DexterityFTI('DxTopicSupport')
        fti.behaviors = (
            'plone.app.dexterity.behaviors.metadata.IBasic',
            'plone.app.content.interfaces.INameFromTitle',
            'ftw.topics.behavior.ITopicSupportSchema',)
        portal_types._setObject('DxTopicSupport', fti)
        fti.lookupSchema()

        transaction.commit()

        self.browser = Browser(self.layer['app'])
        self.browser.addHeader('Authorization', 'Basic %s:%s' % (
                TEST_USER_NAME, TEST_USER_PASSWORD,))
        self.browser.handleErrors = False
Exemplo n.º 31
0
    def test_lookupSchema_with_dynamic_schema(self):
        fti = DexterityFTI(u"testtype")
        fti.schema = None  # use dynamic schema

        portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
        self.mock_utility(portal, ISiteRoot)

        schemaName = utils.portalTypeToSchemaName(fti.getId())
        setattr(plone.dexterity.schema.generated, schemaName, ITestSchema)

        self.assertEqual(ITestSchema, fti.lookupSchema())

        # cleanup
        delattr(plone.dexterity.schema.generated, schemaName)
Exemplo n.º 32
0
    def test_unknown_type_not_cached(self):

        class ISchema1(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(return_value=ISchema1)
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"othertype")
        schema2 = SCHEMA_CACHE.get(u"testtype")
        schema3 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is None)
        self.assertTrue(schema2 is schema3 is ISchema1)
Exemplo n.º 33
0
    def test_repeated_lookup_with_changed_schema(self):
        class ISchema1(Interface):
            pass

        class ISchema2(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(side_effect=[ISchema1, ISchema2])
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"testtype")
        schema2 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is schema2 and schema2 is ISchema1)
Exemplo n.º 34
0
    def test_repeated_lookup_with_changed_schema(self):

        class ISchema1(Interface):
            pass

        class ISchema2(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(side_effect=[ISchema1, ISchema2])
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        schema1 = SCHEMA_CACHE.get(u"testtype")
        schema2 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is schema2 and schema2 is ISchema1)
Exemplo n.º 35
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI(u"testtype")
        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"  # effectively ignored
        fti.model_source = "<model />"
        fti.model_file = None

        model_dummy = Model()

        loadString_mock = self.mocker.replace("plone.supermodel.loadString")
        self.expect(loadString_mock(fti.model_source, policy=u"dexterity")).result(model_dummy)

        self.replay()

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
Exemplo n.º 36
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI(u"testtype")
        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"  # effectively ignored
        fti.model_source = "<model />"
        fti.model_file = None

        model_dummy = Model()

        loadString_mock = self.mocker.replace("plone.supermodel.loadString")
        self.expect(loadString_mock(fti.model_source,
                                    policy=u"dexterity")).result(model_dummy)

        self.replay()

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
Exemplo n.º 37
0
    def test_readfile_mimetype_no_message_no_primary_field(self):
        class ITest(Interface):
            title = schema.TextLine()

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = []

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('text/plain', readfile.mimeType)
Exemplo n.º 38
0
    def test_no_read_permission(self):

        # Mock schema model
        class ITestSchema(Interface):
            test = zope.schema.TextLine(title=u"Test")
        ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(foo='foo.View'))

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ITestSchema)
        fti_mock.behaviors = ()

        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Mock permissions
        self.mock_utility(
            Permission(u'foo.View', u"View foo"), IPermission, u'foo.View'
        )

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        # Check permission
        security_manager_mock = Mock()
        security_manager_mock.checkPermission = Mock(return_value=True)
        from AccessControl import getSecurityManager
        self.patch_global(
            getSecurityManager, return_value=security_manager_mock)

        SCHEMA_CACHE.clear()

        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
        )
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
        )

        # Unknown attributes are allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
        )
Exemplo n.º 39
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI('testtype')
        # effectively ignored:
        fti.schema = 'plone.dexterity.tests.schemata.ITestSchema'
        fti.model_source = '<model />'
        fti.model_file = None

        model_dummy = Model()

        loadString_mock = self.mocker.replace('plone.supermodel.loadString')
        self.expect(loadString_mock(fti.model_source,
                                    policy='dexterity')).result(model_dummy)

        self.replay()

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
Exemplo n.º 40
0
    def test_readfile_mimetype_no_message_no_primary_field(self):

        class ITest(Interface):
            title = schema.TextLine()

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = []

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('text/plain', readfile.mimeType)
Exemplo n.º 41
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI(u"testtype")
        # effectively ignored:
        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"
        fti.model_source = "<model />"
        fti.model_file = None

        model_dummy = Model()

        from plone.supermodel import loadString
        loadString_mock = self.patch_global(
            loadString, return_value=model_dummy)

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
        loadString_mock.assert_called_once_with(
            fti.model_source, policy=u'dexterity')
Exemplo n.º 42
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI(u"testtype")
        # effectively ignored:
        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"
        fti.model_source = "<model />"
        fti.model_file = None

        model_dummy = Model()

        from plone.supermodel import loadString
        loadString_mock = self.patch_global(loadString,
                                            return_value=model_dummy)

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
        loadString_mock.assert_called_once_with(fti.model_source,
                                                policy=u'dexterity')
Exemplo n.º 43
0
    def test_none_not_cached(self):
        class ISchema1(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(side_effect=[None, ISchema1, ISchema1])
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema1 = SCHEMA_CACHE.get(u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema2 = SCHEMA_CACHE.get(u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema3 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is None)
        self.assertTrue(schema2 is schema3 is ISchema1)
Exemplo n.º 44
0
    def test_lookupModel_from_string_with_schema(self):
        fti = DexterityFTI('testtype')
        # effectively ignored:
        fti.schema = 'plone.dexterity.tests.schemata.ITestSchema'
        fti.model_source = '<model />'
        fti.model_file = None

        model_dummy = Model()

        loadString_mock = self.mocker.replace('plone.supermodel.loadString')
        self.expect(
            loadString_mock(fti.model_source, policy='dexterity')
        ).result(model_dummy)

        self.replay()

        model = fti.lookupModel()
        self.assertIs(model_dummy, model)
        self.assertIs(ITestSchema, fti.lookupSchema())
Exemplo n.º 45
0
    def test_no_read_permission(self):

        # Mock schema model
        class ITestSchema(Interface):
            test = zope.schema.TextLine(title=u"Test")

        ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(foo='foo.View'))

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ITestSchema)
        fti_mock.behaviors = ()

        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Mock permissions
        self.mock_utility(Permission(u'foo.View', u"View foo"), IPermission,
                          u'foo.View')

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        # Check permission
        security_manager_mock = Mock()
        security_manager_mock.checkPermission = Mock(return_value=True)
        from AccessControl import getSecurityManager
        self.patch_global(getSecurityManager,
                          return_value=security_manager_mock)

        SCHEMA_CACHE.clear()

        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))

        # Unknown attributes are allowed
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__(
                'random', u"stuff"))
Exemplo n.º 46
0
    def setUpPloneSite(self, portal):
        # install into the Plone site
        applyProfile(portal, 'plone.app.registry:default')
        applyProfile(portal, 'plone.app.dexterity:default')
        applyProfile(portal, 'plone.app.intid:default')
        applyProfile(portal, 'plone.app.standardtiles:default')

        # Creates some users
        acl_users = getToolByName(portal, 'acl_users')
        acl_users.userFolderAddUser(
            self.NORMAL_USER_NAME,
            self.NORMAL_USER_PASSWORD,
            ['Member'],
            [],
        )
        acl_users.userFolderAddUser(
            self.EDITOR_USER_NAME,
            self.EDITOR_USER_PASSWORD,
            ['Editor'],
            [],
        )
        acl_users.userFolderAddUser(
            self.MANAGER_USER_NAME,
            self.MANAGER_USER_PASSWORD,
            ['Manager'],
            [],
        )

        # Define the dexterity "junk" type
        fti = DexterityFTI('DecoTestType1')
        fti.schema = u'plone.app.standardtiles.testing.ITestType1'
        fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IDublinCore',)
        portal.portal_types._setObject('DecoTestType1', fti)
        schema = fti.lookupSchema()

        # inserts the content of the types defined above
        login(portal, self.MANAGER_USER_NAME)
        content = portal[portal.invokeFactory('DecoTestType1',
                                              'deco-test-type1')]
        content.title = u"Test content"
        content.description = u"Just a test content"
        content.contributors = (u'Jane Doe', u'John Doe')
        logout()
Exemplo n.º 47
0
    def test_readfile_mimetype_no_message_multiple_primary_fields(self):
        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()
            stuff = schema.Bytes()

        alsoProvides(ITest['body'], IPrimaryField)
        alsoProvides(ITest['stuff'], IPrimaryField)

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('message/rfc822', readfile.mimeType)
Exemplo n.º 48
0
    def test_primary_field_info(self):

        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()
        alsoProvides(ITest['body'], IPrimaryField)

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(return_value=ITest)
        fti.behaviors = []
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'
        item.body = u'body text'

        info = PrimaryFieldInfo(item)
        assert info.fieldname == 'body'
        assert info.field == ITest['body']
        assert info.value == 'body text'
Exemplo n.º 49
0
    def test_primary_field_info(self):
        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()

        alsoProvides(ITest['body'], IPrimaryField)

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(return_value=ITest)
        fti.behaviors = []
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'
        item.body = u'body text'

        info = PrimaryFieldInfo(item)
        assert info.fieldname == 'body'
        assert info.field == ITest['body']
        assert info.value == 'body text'
Exemplo n.º 50
0
    def test_readfile_mimetype_no_message_multiple_primary_fields(self):

        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()
            stuff = schema.Bytes()
        alsoProvides(ITest['body'], IPrimaryField)
        alsoProvides(ITest['stuff'], IPrimaryField)

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('message/rfc822', readfile.mimeType)
Exemplo n.º 51
0
    def test_none_not_cached(self):

        class ISchema1(Interface):
            pass

        fti = DexterityFTI(u"testtype")
        fti.lookupSchema = Mock(side_effect=[None, ISchema1, ISchema1])
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema1 = SCHEMA_CACHE.get(u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema2 = SCHEMA_CACHE.get(u"testtype")

        SCHEMA_CACHE.invalidate('testtype')
        schema3 = SCHEMA_CACHE.get(u"testtype")

        self.assertTrue(schema1 is None)
        self.assertTrue(schema2 is schema3 is ISchema1)
Exemplo n.º 52
0
    def test_update_checks_allowed_types(self):

        # Context and request
        context_mock = self.create_dummy(portal_type=u'testtype',
                                         allowedContentTypes=lambda: [])
        request_mock = TestRequest()

        # FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=ISchema)
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        self.mock_adapter(FieldWidgets, IWidgets,
                          (Interface, Interface, Interface))

        self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))

        # Form
        view = DefaultAddForm(context_mock, request_mock)
        view.portal_type = fti_mock.getId()
        self.assertRaises(ValueError, view.update)
Exemplo n.º 53
0
    def test_readfile_mimetype_additional_schemata(self):
        # This is mostly a test that utils.iterSchemata takes
        # IBehaviorAssignable into account.

        class ITest(Interface):
            title = schema.TextLine()

        class ITestAdditional(Interface):
            # Additional behavior on an item
            body = schema.Text()
            stuff = schema.Bytes()

        alsoProvides(ITestAdditional['body'], IPrimaryField)
        alsoProvides(ITestAdditional['stuff'], IPrimaryField)
        alsoProvides(ITestAdditional, IFormFieldProvider)

        class MockBehavior(object):
            def __init__(self, iface):
                self.interface = iface

        class MockBehaviorAssignable(object):
            def __init__(self, context):
                self.context = context

            def enumerateBehaviors(self):
                yield MockBehavior(ITestAdditional)

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)

        self.mock_adapter(MockBehaviorAssignable, IBehaviorAssignable,
                          (Item, ))
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('message/rfc822', readfile.mimeType)
Exemplo n.º 54
0
    def test_readfile_mimetype_additional_schemata(self):
        # This is mostly a test that utils.iterSchemata takes
        # IBehaviorAssignable into account.

        class ITest(Interface):
            title = schema.TextLine()

        class ITestAdditional(Interface):
            # Additional behavior on an item
            body = schema.Text()
            stuff = schema.Bytes()
        alsoProvides(ITestAdditional['body'], IPrimaryField)
        alsoProvides(ITestAdditional['stuff'], IPrimaryField)
        alsoProvides(ITestAdditional, IFormFieldProvider)

        class MockBehavior(object):
            def __init__(self, iface):
                self.interface = iface

        class MockBehaviorAssignable(object):
            def __init__(self, context):
                self.context = context

            def enumerateBehaviors(self):
                yield MockBehavior(ITestAdditional)

        SCHEMA_CACHE.clear()
        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)

        self.mock_adapter(MockBehaviorAssignable, IBehaviorAssignable,
                          (Item, ))
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        self.assertEqual('message/rfc822', readfile.mimeType)
Exemplo n.º 55
0
    def test_getSize(self):
        class SizedValue(str):
            def getSize(self):
                return len(self)

        class ITest(Interface):
            field1 = zope.schema.TextLine()

        class ITestBehavior(Interface):
            field2 = zope.schema.TextLine()
        alsoProvides(ITestBehavior, IFormFieldProvider)

        self.mock_adapter(
            DexterityBehaviorAssignable,
            IBehaviorAssignable,
            (IDexterityContent,)
        )

        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = ['test_behavior']
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        behavior_reg = BehaviorRegistration(
            u"Test Behavior",
            "",
            ITestBehavior,
            ITestBehavior,
            None
        )
        self.mock_utility(behavior_reg, IBehavior, name="test_behavior")

        item = Item('item')
        item.portal_type = 'testtype'
        item.field1 = SizedValue('1')
        item.field2 = SizedValue('22')

        self.assertEqual(3, item.getSize())
Exemplo n.º 56
0
    def test_no_schema(self):

        # Mock FTI
        fti_mock = DexterityFTI(u"testtype")
        fti_mock.lookupSchema = Mock(return_value=None)
        fti_mock.behaviors = ()
        self.mock_utility(fti_mock, IDexterityFTI, u'testtype')

        # Content item
        item = Item('test')
        item.portal_type = u"testtype"
        item.test = u"foo"
        item.foo = u"bar"

        SCHEMA_CACHE.clear()

        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
        self.assertTrue(
            item.__allow_access_to_unprotected_subobjects__(
                'random', u"stuff"))
Exemplo n.º 57
0
    def test_readfile_operations(self):
        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()

        alsoProvides(ITest['body'], IPrimaryField)

        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = [ITestBehavior.__identifier__]

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'

        readfile = DefaultReadFile(item)

        message = Message()
        message['title'] = 'Test title'
        message['foo'] = '10'
        message['bar'] = 'xyz'
        message.set_payload('<p>body</p>')

        from plone.rfc822 import constructMessageFromSchemata
        self.patch_global(constructMessageFromSchemata, return_value=message)

        body = """\
title: Test title
foo: 10
bar: xyz
Portal-Type: testtype

<p>body</p>"""

        # iter
        # next

        self.assertEqual(body, readfile.read())
        self.assertEqual(69, readfile.size())
        self.assertEqual('utf-8', readfile.encoding)
        self.assertEqual(None, readfile.name)
        self.assertEqual('text/plain', readfile.mimeType)

        readfile.seek(2)
        self.assertEqual(2, readfile.tell())
        self.assertEqual('tl', readfile.read(2))
        self.assertEqual(4, readfile.tell())

        readfile.seek(0, 2)
        self.assertEqual(69, readfile.tell())

        readfile.seek(0)
        self.assertEqual('foo: 10\n', readfile.readlines()[1])

        readfile.seek(0)
        self.assertEqual('foo: 10\n', readfile.readlines(100)[1])

        readfile.seek(0)
        self.assertEqual('title: Test title\n', readfile.readline())

        readfile.seek(0)
        self.assertEqual('title: Test title\n', readfile.readline(100))

        readfile.seek(0)
        self.assertEqual('foo: 10\n', list(iter(readfile))[1])

        self.assertEqual(False, readfile.closed)
        readfile.close()
Exemplo n.º 58
0
    def test_writefile_file_operations(self):
        class ITest(Interface):
            title = schema.TextLine()
            body = schema.Text()

        alsoProvides(ITest['body'], IPrimaryField)

        fti_mock = DexterityFTI(u'testtype')
        fti_mock.lookupSchema = Mock(return_value=ITest)
        fti_mock.behaviors = [ITestBehavior.__identifier__]

        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        item = Item('item')
        item.portal_type = 'testtype'
        item.title = u"Test title"
        item.foo = 10
        item.bar = 'xyz'
        item.body = u"<p>body</p>"

        writefile = DefaultWriteFile(item)

        body = """\
title: Test title
foo: 10
bar: xyz
Portal-Type: testtype

<p>body</p>"""

        from plone.rfc822 import initializeObjectFromSchemata
        self.patch_global(initializeObjectFromSchemata)

        writefile.mimeType = 'text/plain'
        self.assertEqual('text/plain', writefile.mimeType)

        writefile.encoding = 'latin1'
        self.assertEqual('latin1', writefile.encoding)

        writefile.filename = 'test.html'
        self.assertEqual('test.html', writefile.filename)

        self.assertEqual(False, writefile.closed)
        self.assertEqual(0, writefile.tell())

        writefile.writelines(['one\n', 'two'])
        self.assertEqual(7, writefile.tell())

        self.assertRaises(NotImplementedError, writefile.truncate)

        writefile.truncate(0)
        self.assertEqual(0, writefile.tell())

        self.assertRaises(NotImplementedError, writefile.seek, 10)

        writefile.write(body[:10])
        writefile.write(body[10:])
        writefile.close()

        self.assertEqual(True, writefile.closed)
        self.assertEqual(69, writefile.tell())
Exemplo n.º 59
0
 def test_lookupSchema_with_concrete_schema(self):
     fti = DexterityFTI('testtype')
     fti.schema = 'plone.dexterity.tests.schemata.ITestSchema'
     self.assertEqual(ITestSchema, fti.lookupSchema())
     # second time uses _v attribute
     self.assertEqual(ITestSchema, fti.lookupSchema())