[Zope3-checkins] CVS: Zope3/src/zope/app/site/browser/ftests - test_utilitytools.py:1.1

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Mar 21 19:52:11 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/site/browser/ftests
In directory cvs.zope.org:/tmp/cvs-serv1163/src/zope/app/site/browser/ftests

Added Files:
	test_utilitytools.py 
Log Message:


Implemented tests for utility tool management UI.




=== Added File Zope3/src/zope/app/site/browser/ftests/test_utilitytools.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.
#
##############################################################################
"""Utility Tools Functional Tests

$Id: test_utilitytools.py,v 1.1 2004/03/22 00:52:10 srichter Exp $
"""
import unittest

from zope.app import zapi
from zope.i18n.interfaces import ITranslationDomain
from zope.app.registration.interfaces import ActiveStatus, RegisteredStatus
from zope.testing.functional import BrowserTestCase

class TestUtilityTool(BrowserTestCase):

    def testContent(self):
        path = '/++etc++site/@@manageITranslationDomainTool.html'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')
        self.assertEqual(response.getStatus(), 200)

        body = response.getBody()

        # test for broken links
        self.checkForBrokenLinks(body, path, basic='mgr:mgrpw')

        # We can't really test more here, since we do not know what type of
        # utilities will registered as tools.

    def testAdd(self):
        path = '/++etc++site/@@AddITranslationDomainTool'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')
        self.assertEqual(response.getStatus(), 200)

        body = response.getBody()

        # test for broken links
        self.checkForBrokenLinks(body, path, basic='mgr:mgrpw')

        # attempt to add something
        response = self.publish(
            path+'/action.html', basic='mgr:mgrpw',
            form={'type_name': 'zope.app.browser.add.TranslationDomain.f1',
                  'id': 'zope',
                  'add': 'Add'})

        root = self.getRootFolder()
        tools = zapi.traverse(root, '/++etc++site/tools')
        self.assert_('zope' in tools.keys())

    def testDelete(self):
        path = '/++etc++site/@@AddITranslationDomainTool'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')

        self.publish(
            path + '/action.html',
            basic='mgr:mgrpw',
            form={'type_name': 'zope.app.browser.add.TranslationDomain.f1',
                  'id': 'zope',
                  'add': 'Add'})

        response = self.publish(
            '/++etc++site/@@manageITranslationDomainTool.html',
            basic='mgr:mgrpw',
            form={'selected': ['zope'],
                  'DELETE': 'Delete'})

        root = self.getRootFolder()
        tools = zapi.traverse(root, '/++etc++site/tools')
        self.assert_('zope' not in tools.keys())

    def testRename(self):
        path = '/++etc++site/@@AddITranslationDomainTool'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')

        self.publish(
            path + '/action.html',
            basic='mgr:mgrpw',
            form={'type_name': 'zope.app.browser.add.TranslationDomain.f1',
                  'id': 'zope',
                  'add': 'Add'})

        response = self.publish(
            '/++etc++site/@@manageITranslationDomainTool.html',
            basic='mgr:mgrpw',
            form={'selected': ['zope'],
                  'old_names': ['zope'],
                  'new_names': ['newzope'],
                  'APPLY_RENAME': 'Rename'})

        root = self.getRootFolder()
        util = zapi.queryUtility(root, ITranslationDomain, name='newzope')
        self.assert_(util is not None)

    def testDeactivate(self):
        path = '/++etc++site/@@AddITranslationDomainTool'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')

        self.publish(
            path + '/action.html',
            basic='mgr:mgrpw',
            form={'type_name': 'zope.app.browser.add.TranslationDomain.f1',
                  'id': 'zope',
                  'add': 'Add'})

        response = self.publish(
            '/++etc++site/@@manageITranslationDomainTool.html',
            basic='mgr:mgrpw',
            form={'selected': ['zope'],
                  'DEACTIVATE': 'Rename'})

        root = self.getRootFolder()
        utils = zapi.getService(root, 'Utilities')
        reg = utils.queryRegistrations('zope', ITranslationDomain)

        for info in reg.info():
            self.assert_(info['registration'].status == RegisteredStatus)
            
    def testActivate(self):
        path = '/++etc++site/@@AddITranslationDomainTool'
        # create the view
        response = self.publish(path, basic='mgr:mgrpw')

        self.publish(
            path + '/action.html',
            basic='mgr:mgrpw',
            form={'type_name': 'zope.app.browser.add.TranslationDomain.f1',
                  'id': 'zope',
                  'add': 'Add'})

        response = self.publish(
            '/++etc++site/@@manageITranslationDomainTool.html',
            basic='mgr:mgrpw',
            form={'selected': ['zope'],
                  'DEACTIVATE': 'Rename'})

        response = self.publish(
            '/++etc++site/@@manageITranslationDomainTool.html',
            basic='mgr:mgrpw',
            form={'selected': ['zope'],
                  'ACTIVATE': 'Rename'})

        root = self.getRootFolder()
        utils = zapi.getService(root, 'Utilities')
        reg = utils.queryRegistrations('zope', ITranslationDomain)

        for info in reg.info():
            self.assert_(info['registration'].status == ActiveStatus)

        
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestUtilityTool))
    return suite

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




More information about the Zope3-Checkins mailing list