[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol/browser/tests - __init__.py:1.1 test_runtimeinfoview.py:1.1 test_servercontrolview.py:1.1

Philipp von Weitershausen philikon at philikon.de
Mon Mar 1 08:43:27 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv19445/applicationcontrol/browser/tests

Added Files:
	__init__.py test_runtimeinfoview.py test_servercontrolview.py 
Log Message:
Moved browser views and interfaces for applicationcontrol to the
zope.app.applicationcontrol package.


=== Added File Zope3/src/zope/app/applicationcontrol/browser/tests/__init__.py ===
#
# This file is necessary to make this directory a package.


=== Added File Zope3/src/zope/app/applicationcontrol/browser/tests/test_runtimeinfoview.py ===
##############################################################################
#
# Copyright (c) 2001, 2002, 2003 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.
#
##############################################################################
"""Runtime View tests

$Id: test_runtimeinfoview.py,v 1.1 2004/03/01 13:43:25 philikon Exp $
"""
import unittest
from types import DictType
from zope.app.tests import ztapi

from zope.app.applicationcontrol.applicationcontrol import applicationController
from zope.app.applicationcontrol.runtimeinfo import RuntimeInfo
from zope.app.applicationcontrol.browser.runtimeinfo import RuntimeInfoView
from zope.app.applicationcontrol.interfaces import \
     IApplicationControl, IRuntimeInfo
from zope.app.services.tests.placefulsetup import PlacefulSetup

class Test(PlacefulSetup, unittest.TestCase):

    def _TestView__newView(self, container):
        view = RuntimeInfoView()
        view.context = container
        view.request = None
        return view

    def test_RuntimeInfoView(self):
        ztapi.provideAdapter(IApplicationControl, IRuntimeInfo, RuntimeInfo)
        test_runtimeinfoview = self._TestView__newView(applicationController)

        test_format = test_runtimeinfoview.runtimeInfo()
        self.failUnless(isinstance(test_format, DictType))

        assert_keys = ['ZopeVersion', 'PythonVersion', 'PythonPath',
              'SystemPlatform', 'CommandLine', 'ProcessId', 'Uptime' ]
        test_keys = test_format.keys()

        assert_keys.sort()
        test_keys.sort()
        self.failUnless(assert_keys == test_keys)

        self.failUnless(test_format["ZopeVersion"] != "N/A")

    def test_RuntimeInfoFailureView(self):
        test_runtimeinfoview = self._TestView__newView(applicationController)

        test_format = test_runtimeinfoview.runtimeInfo()
        self.failUnless(isinstance(test_format, DictType))

        assert_keys = ['ZopeVersion', 'PythonVersion', 'PythonPath',
              'SystemPlatform', 'CommandLine', 'ProcessId', 'Uptime', 'Hint']
        test_keys = test_format.keys()

        assert_keys.sort()
        test_keys.sort()
        self.failUnless(assert_keys == test_keys)

        self.failUnless(test_format["ZopeVersion"] == "N/A")


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

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


=== Added File Zope3/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py ===
##############################################################################
#
# Copyright (c) 2001, 2002, 2003 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.
#
##############################################################################
"""Server Control View Tests

$Id: test_servercontrolview.py,v 1.1 2004/03/01 13:43:25 philikon Exp $
"""
import unittest

from zope.app.applicationcontrol.applicationcontrol import applicationController
from zope.app.applicationcontrol.servercontrol import ServerControl
from zope.app.applicationcontrol.browser.servercontrol import ServerControlView
from zope.app.applicationcontrol.interfaces import IServerControl
from zope.app.services.servicenames import Utilities
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.component import getService

class Test(PlacefulSetup, unittest.TestCase):

    def _TestView__newView(self, container, request):
        view = ServerControlView()
        view.context = container
        view.request = request
        return view

    def test_ServerControlView(self):
        getService(None,Utilities).provideUtility(
              IServerControl, ServerControl())

        test_serverctrl = self._TestView__newView(
            applicationController,
            {'shutdown': 1},
            )
        test_serverctrl.action()

        test_serverctrl = self._TestView__newView(
            applicationController,
            {'restart': 1},
            )
        test_serverctrl.action()


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

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




More information about the Zope3-Checkins mailing list