Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

Setting up a dummy vocabulary for a doctest

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


charlie.clark at clark-consulting

Sep 18, 2010, 10:23 AM

Post #1 of 2 (562 views)
Permalink
Setting up a dummy vocabulary for a doctest

Hi,

I'm writing tests for my replacement views. In the preferences form I use
a vocabulary to list the possible skin choices. For testing the forms I'm
generally using doctests to check the rendered HTML but I haven't been
able to work out how to add get a dummy vocabulary to work with the test
although it is correctly registered. This is from my doctest:

Set up dummy skins vocabulary
>>> from zope.schema.interfaces import IVocabularyFactory
>>> from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
>>> terms = [SimpleTerm('default', 'default', 'default'),
SimpleTerm('fancy', 'fancy', 'fancy')]
>>> vocab = lambda: SimpleVocabulary(terms)
>>> from zope.component import getSiteManager
>>> sm = getSiteManager()
>>> sm.registerUtility(vocab, IVocabularyFactory, u'cmf.portal_skins')

But as soon as I call the preferences form I get (after logging in)

>> browser.open("http://localhost/site/@@preferences.html")

Error Value:\n unknown vocabulary: u\'cmf.portal_skins\'

Any ideas?

I've commited the doctest with the failing issues commented out.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
_______________________________________________
Zope-CMF maillist - Zope-CMF [at] zope
https://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


charlie.clark at clark-consulting

Sep 25, 2010, 1:48 PM

Post #2 of 2 (508 views)
Permalink
Re: Setting up a dummy vocabulary for a doctest [In reply to]

Am 18.09.2010, 19:23 Uhr, schrieb Charlie Clark
<charlie.clark [at] clark-consulting>:

> Error Value:\n unknown vocabulary: u\'cmf.portal_skins\'
> Any ideas?

Okay, figured this out because I've had it before! Relevant vocabularies
can be registered when setting up the doctest:


from Products.CMFDefault.browser.content.tests.utils import clearVocabulary
from Products.CMFDefault.browser.content.tests.utils import setupVocabulary

ftest_suite = ZopeTestCase.FunctionalDocFileSuite('preferences.txt',
setUp=setupVocabulary,
tearDown=clearVocabulary,
)

Now, let's see how long I actually remember how to do this!

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
_______________________________________________
Zope-CMF maillist - Zope-CMF [at] zope
https://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.