[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/site/browser/ Fixed
the broken Services summary view, added a functional test and a unit
Albertas Agejevas
alga at pov.lt
Wed May 26 10:07:16 EDT 2004
Log message for revision 25007:
Fixed the broken Services summary view, added a functional test and a unit
test.
-=-
Modified: Zope3/trunk/src/zope/app/site/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/site/browser/__init__.py 2004-05-26 13:52:31 UTC (rev 25006)
+++ Zope3/trunk/src/zope/app/site/browser/__init__.py 2004-05-26 14:07:15 UTC (rev 25007)
@@ -29,7 +29,7 @@
from zope.app.publisher.browser import BrowserView
from zope.app.site.interfaces import ISite, ISiteManager
from zope.app.site.service import SiteManager
-from zope.app.component.localservice import getLocalServices
+from zope.app.component.localservice import getNextServices
from zope.component.service import IGlobalServiceManager
from zope.component.interfaces import IFactory
from zope.interface.interfaces import IMethod
@@ -126,7 +126,7 @@
path = zapi.name(content)
rm = content.__parent__.getRegistrationManager()
chooser = INameChooser(rm)
-
+
# register an activated service registration
for type_name in implements:
sc = ServiceRegistration(type_name, path, content)
@@ -317,7 +317,7 @@
# don't want the "change registration" link for parent services
manageable = False
- if IGlobalServiceService.providedBy(sm):
+ if IGlobalServiceManager.providedBy(sm):
# global service manager
names = []
for type_name, interface in sm.getServiceDefinitions():
@@ -350,7 +350,7 @@
'disabled': not url, 'manageable': manageable}
# look for more
- gatherConfiguredServices(getLocalService(sm), request, items)
+ gatherConfiguredServices(getNextServices(sm), request, items)
# make it a list and sort by name
items = items.values()
Added: Zope3/trunk/src/zope/app/site/browser/ftests/test_services.py
===================================================================
--- Zope3/trunk/src/zope/app/site/browser/ftests/test_services.py 2004-05-26 13:52:31 UTC (rev 25006)
+++ Zope3/trunk/src/zope/app/site/browser/ftests/test_services.py 2004-05-26 14:07:15 UTC (rev 25007)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Services overview functional tests
+
+$Id$
+"""
+import unittest
+
+from zope.app.tests.functional import BrowserTestCase
+
+
+class TestServices(BrowserTestCase):
+
+ def test(self):
+ path = '/++etc++site/@@services.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')
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestServices))
+ return suite
+
+if __name__=='__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Zope3/trunk/src/zope/app/site/browser/ftests/test_services.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: Zope3/trunk/src/zope/app/site/browser/tests/test_services.py
===================================================================
--- Zope3/trunk/src/zope/app/site/browser/tests/test_services.py 2004-05-26 13:52:31 UTC (rev 25006)
+++ Zope3/trunk/src/zope/app/site/browser/tests/test_services.py 2004-05-26 14:07:15 UTC (rev 25007)
@@ -0,0 +1,65 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Unit tests for service summary view
+
+$Id$
+"""
+import unittest
+from zope.app.tests import ztapi
+from zope.publisher.browser import TestRequest
+from zope.app.tests import setup
+from zope.app.site.interfaces import ILocalService
+from zope.interface import implements
+
+class ServiceStub:
+ __parent__ = None
+ __name__ = None
+ next = None
+ implements(ILocalService)
+
+class TestServices(unittest.TestCase):
+
+ def setUp(self):
+ root = setup.placefulSetUp(True)
+ self.sm = setup.createServiceManager(root)
+ setup.addService(self.sm, 'Utilities', ServiceStub())
+
+ def tearDown(self):
+ setup.placefulTearDown()
+
+ def test(self):
+ from zope.app.site.browser import gatherConfiguredServices
+ expected = [{'url': '', 'disabled': False, 'manageable': False,
+ 'name': 'Adapters', 'parent': u'global'},
+ {'url': '', 'disabled': False, 'manageable': False,
+ 'name': 'EventPublication', 'parent': u'global'},
+ {'url': '', 'disabled': False, 'manageable': False,
+ 'name': 'Presentation', 'parent': u'global'},
+ {'url': '', 'disabled': False, 'manageable': False,
+ 'name': 'Services', 'parent': u'global'},
+ {'url': 'http://127.0.0.1/++etc++site/default/Utilities',
+ 'disabled': False, 'manageable': True,
+ 'name': 'Utilities', 'parent': u'parent'}]
+ request = TestRequest()
+ results = gatherConfiguredServices(self.sm, request)
+ self.assertEqual(results, expected)
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestServices))
+ return suite
+
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: Zope3/trunk/src/zope/app/site/browser/tests/test_services.py
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the Zope3-Checkins
mailing list