[Zope] Writing Unit test

Robert Rottermann robert@redcor.ch
Wed, 17 Apr 2002 13:40:19 +0200


I am starting to write unit tests.( better late than never)

In one of the tests I need to create a new instance of a product  that adds
several subobjects (user_folder, properies, ..) to its container.
in "normal" Zope I do that with :
container.manage_addProduct['RedInfopool'].addUserFolderWithGroups()

When I do the same in a test like so:

    def CreateTestFolder ( self, ret=0 ) :
        ob = Folder()
        id = 'test_folder'
        ob.id=str(id)
        ob.title=str('contains test data')
        id = self.root._setObject(ob.id, ob)
        ob = getattr(self.root, id)
        ob.manage_addProduct['RedInfopool'].addUserFolderWithGroups()
        self.failUnless(ob.getId() == id, 'could not create test folder')

ob.mangae_add .... fails.
It does not have a "context" obviously.
How do I add such a context?
Is there a sample somewhere?

thank you

Robert

www.redcor.ch