I don't know why this post was not sent here yesterday...

Hi Hector,

finally my extender is working the way I wanted; thanks for your help, man!

Yay! :)

now I'm writing some tests to verify that everything is fine; I found one issue 
and something not working (at least, not for me) in your doctest:

Does my doctest run if you run all the schemaextender tests? They all pass 
here, so I suspect there's something wrong with your test setup.

first, *usage.txt* starting on line 142:

     >>> schema = taggable_doc.Schema()
     >>> 'schemaextender_test_tags' in schema
     False
     >>> 'schemaextender_test_highlighted' in schema
     False

If it doesn't work, then your adapter isn't registered in your test.

this doesn't work at all; I changed to something like this:

class TestNewsItem(JuliusLiteTestCase):
     """ ensure content type implementation """

     def afterSetUp(self):
         self.folder.invokeFactory('News Item', 'news1')
         self.news1 = getattr(self.folder, 'news1')

     def testExtendedFields(self):
         extended_fields = ['property', 'section', 'urgency', 'byline']
         schema = getNames(self.news1.Schema())
         for field in extended_fields:
             self.failUnless(field in schema)

so you're missing the getNames() method.

Huh? getNames() is a global method in that code. I don't know where you 
imported it from or why you're using it. Is this working for you?

/me thinks ...

this may be a Plone 2.5/AT 1.4 discrepancy; I haven't tried it on that platform 
as you nkow.

second, *usage.txt* starting on line 33:

     >>> self.folder.invokeFactory('Document', 'taggable-document')
     'taggable-document'

     >>> taggable_doc = getattr(self.folder, 'taggable-document')
     >>> ITaggable.providedBy(taggable_doc)
     True

this doesn't work for me:

class TestExtender(JuliusLiteTestCase):
     """ ensure extender implementation """

     def afterSetUp(self):
         zope.component.provideAdapter(NITFExtender, provides=ISchemaExtender, 
name=u'Products.nitf4plone.extender')
         self.folder.invokeFactory('News Item', 'news1')
         self.news1 = getattr(self.folder, 'news1')

     def testProvidesSchemaExtender(self):
         self.failUnless(ISchemaExtender.providedBy(self.news1))

     def testProvidesSchemaModifier(self):
         self.failUnless(ISchemaModifier.providedBy(self.news1))

both methods fail.

Well, it'd only work if you had a field that actually did what the 
TaggableField or whatever it's called does in the usage.txt text. It's an 
example of something you may do with at.se, not something you'll see every time.

I tried also:

         #this one fails
         self.failUnless(verifyObject(ISchemaExtender, self.news1))
         #this one pass
         self.failUnless(verifyClass(ISchemaExtender, ATNewsItem))

Why did you try this? It's non-sensical. ISchemaExtender is an *adapter*. 
verifyObject/Class tests whether a particular interface is *provided by* an 
instance/class. It'll never pass.

Martin



_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to