[Zope3-checkins] CVS: zopeproducts/zwiki/tests - test_traversable.py:1.1 test_traverser.py:1.1 test_wiki.py:1.3

Stephan Richter srichter@cbu.edu
Wed, 9 Apr 2003 09:41:31 -0400


Update of /cvs-repository/zopeproducts/zwiki/tests
In directory cvs.zope.org:/tmp/cvs-serv3233/tests

Modified Files:
	test_wiki.py 
Added Files:
	test_traversable.py test_traverser.py 
Log Message:
- Added FTP (File) Views for WikiPages.

- Added Traversable in addition Traverser.

- Wrote tests for Traversable and Traverser.

- Added renderer test directory.

- Moved from traverser.py to traversable.py to conform to convention.


=== Added File zopeproducts/zwiki/tests/test_traversable.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""

$Id: test_traversable.py,v 1.1 2003/04/09 13:41:29 srichter Exp $
"""
import unittest, sys
from zope.exceptions import NotFoundError
from zope.testing.cleanup import CleanUp
from zope.proxy.context import ContextWrapper

from zopeproducts.zwiki.zwiki import Wiki, WikiPage
from zopeproducts.zwiki.traversal import WikiPageTraversable


class TestTraversable(CleanUp, unittest.TestCase):
    def testAttr(self):
        # test container path traversal
        wiki = Wiki()
        page1 = WikiPage()
        page2 = WikiPage()
        wiki.setObject('FrontPage', page1)
        wiki.setObject('FooBar', page2)

        T = WikiPageTraversable(ContextWrapper(page1, wiki, name='FrontPage'))
        self.failUnless(T.traverse('FooBar', (), 'FooBar', []) is page2)

        self.assertRaises(NotFoundError , T.traverse,
                          'morebar', (), 'morebar', [])


def test_suite():
    return unittest.TestSuite((
        unittest.makeSuite(TestTraversable),
        ))

if __name__ == '__main__':
    unittest.main()


=== Added File zopeproducts/zwiki/tests/test_traverser.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""

$Id: test_traverser.py,v 1.1 2003/04/09 13:41:29 srichter Exp $
"""

import unittest, sys
from zope.component.tests.request import Request
from zope.component import getService
from zope.app.services.servicenames import Views
from zope.interface import Interface
from zope.exceptions import NotFoundError
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.proxy.introspection import removeAllProxies
from zope.proxy.context import ContextWrapper

from zopeproducts.zwiki.interfaces import IWikiPage
from zopeproducts.zwiki.zwiki import Wiki, WikiPage
from zopeproducts.zwiki.traversal import WikiPageTraverser

class I(Interface):
    pass


class Request(Request):
    def getEffectiveURL(self):
        return ''


class View:
    def __init__(self, comp, request):
        self._comp = comp


class TestTraverser(PlacelessSetup, unittest.TestCase):
    def testAttr(self):
        wiki = Wiki()
        page1 = WikiPage()
        page2 = WikiPage()
        wiki.setObject('FrontPage', page1)
        wiki.setObject('FooBar', page2)
        request = Request(I, '')

        T = WikiPageTraverser(ContextWrapper(page1, wiki, name='FrontPage'),
                              request)
        self.failUnless(
            removeAllProxies(T.publishTraverse(request, 'FooBar')) is page2)

        self.assertRaises(NotFoundError, T.publishTraverse, request,'morebar')


    def testView(self):
        wiki = Wiki()
        page1 = WikiPage()
        page2 = WikiPage()
        wiki.setObject('FrontPage', page1)
        wiki.setObject('FooBar', page2)
        request = Request(I, '')

        T = WikiPageTraverser(ContextWrapper(page1, wiki, name='FrontPage'),
                              request)
        getService(None, Views).provideView(IWikiPage, 'viewfoo', I, [View])

        self.failUnless(
            T.publishTraverse(request, 'viewfoo').__class__ is View )
        self.failUnless(
            removeAllProxies(T.publishTraverse(request, 'FooBar')) is page2)

        self.assertRaises(NotFoundError, T.publishTraverse, request, 'morebar')
        self.assertRaises(NotFoundError, T.publishTraverse, request,
                          '@@morebar')


def test_suite():
    return unittest.TestSuite((
        unittest.makeSuite(TestTraverser),
        ))

if __name__ == '__main__':
    unittest.main()


=== zopeproducts/zwiki/tests/test_wiki.py 1.2 => 1.3 ===
--- zopeproducts/zwiki/tests/test_wiki.py:1.2	Sat Apr  5 16:38:11 2003
+++ zopeproducts/zwiki/tests/test_wiki.py	Wed Apr  9 09:41:29 2003
@@ -34,11 +34,11 @@
     def test_interface(self):
         self.assert_(IWiki.isImplementedBy(self.makeTestObject()))
 
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(Test),
         ))
-
 
 if __name__ == '__main__':
     unittest.main()