[Zope3-checkins] CVS: Zope3/src/zope/app/apidoc/viewmodule - ftests.py:1.1 tests.py:1.1

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Mar 28 18:41:56 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/apidoc/viewmodule
In directory cvs.zope.org:/tmp/cvs-serv23259/src/zope/app/apidoc/viewmodule

Added Files:
	ftests.py tests.py 
Log Message:


Added tests.




=== Added File Zope3/src/zope/app/apidoc/viewmodule/ftests.py ===
##############################################################################
#
# Copyright (c) 2003, 2004 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.
#
##############################################################################
"""Functional Tests for Presentation Documentation Module.

$Id: ftests.py,v 1.1 2004/03/28 23:41:55 srichter Exp $
"""
import unittest
from zope.testing.functional import BrowserTestCase

class ViewModuleTests(BrowserTestCase):
    """Just a couple of tests ensuring that the templates render."""

    def testMenu(self):
        response = self.publish('/++apidoc++/Views/menu.html', 
                                basic='mgr:mgrpw')
        self.assertEqual(response.getStatus(), 200)
        body = response.getBody()
        self.assert_(body.find('Show Skins and Layers') > 0)
        self.checkForBrokenLinks(body, '/++apidoc++/Views/menu.html',
                                 basic='mgr:mgrpw')


    def testSkinsLayersView(self):
        response = self.publish('/++apidoc++/Views/skin_layer.html',
                                basic='mgr:mgrpw')
        self.assertEqual(response.getStatus(), 200)
        body = response.getBody()
        self.assert_(body.find('Skin-Layer Tree') > 0)

    def testViewsDetails(self):
        response = self.publish(
            '/++apidoc++/Views/index.html',
            form={'iface': 'zope.app.apidoc.interfaces.IDocumentationModule',
                  'type': 'zope.publisher.interfaces.browser.IBrowserRequest',
                  'all': 'all'},
            basic='mgr:mgrpw')
        self.assertEqual(response.getStatus(), 200)
        body = response.getBody()
        self.assert_(body.find(
            'IBrowserRequest views for \n    IDocumentationModule') > 0)
        self.checkForBrokenLinks(
            body, '/++apidoc++/Views/index.html',
            basic='mgr:mgrpw')
        

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

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


=== Added File Zope3/src/zope/app/apidoc/viewmodule/tests.py ===
##############################################################################
#
# Copyright (c) 2004 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.
#
##############################################################################
"""Tests for the Class Documentation Module

$Id: tests.py,v 1.1 2004/03/28 23:41:55 srichter Exp $
"""
import unittest
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.testing.doctestunit import DocTestSuite
from zope.app import zapi
from zope.app.apidoc.tests import pprintDict
from zope.app.tests import placelesssetup, ztapi
from zope.app.component.interface import provideInterface

class IFoo(Interface):
    pass

class FooView:
    pass

def setUp():
    placelesssetup.setUp()
    pres = zapi.getService(None, 'Presentation')
    for index in range(1, 6):
        pres.defineLayer('layer'+str(index))
    pres.defineSkin('skinA', ['default'])
    pres.defineSkin('skinB', ['layer5', 'layer4', 'default'])
    pres.defineSkin('skinC', ['layer4', 'layer2', 'layer1', 'default'])

    provideInterface('IFoo', IFoo)
    provideInterface('IBrowserRequest', IBrowserRequest)
    ztapi.browserView(IFoo, 'index.html', FooView, layer='default')
    

def tearDown():
    placelesssetup.tearDown()


def test_suite():
    return unittest.TestSuite((
        DocTestSuite('zope.app.apidoc.viewmodule',
                     setUp=setUp, tearDown=tearDown),
        DocTestSuite('zope.app.apidoc.viewmodule.browser',
                     setUp=setUp, tearDown=tearDown),
        ))

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




More information about the Zope3-Checkins mailing list