Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore testing.PlacelessSetup and friends.
Also move the two new views that were added to tests and out of testing because those are not public APIs.
- Loading branch information
Showing
7 changed files
with
251 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2001-2007 Zope Foundation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (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. | ||
# | ||
############################################################################## | ||
"Non-API test details." | ||
|
||
|
||
from zope.interface import implementer | ||
from zope.publisher.browser import BrowserView | ||
from zope.publisher.interfaces.browser import IBrowserPublisher | ||
from zope.browsermenu.menu import getFirstMenuItem | ||
|
||
|
||
@implementer(IBrowserPublisher) | ||
class ManagementViewSelector(BrowserView): | ||
"""View that selects the first available management view. | ||
Support 'zmi_views' actions like: 'javascript:alert("hello")', | ||
'../view_on_parent.html' or '++rollover++'. | ||
""" | ||
# Copied from zope.app.publication | ||
# Simplified to assert just the test case we expect. | ||
|
||
def browserDefault(self, request): | ||
return self, () | ||
|
||
def __call__(self): | ||
item = getFirstMenuItem('zmi_views', self.context, self.request) | ||
assert item | ||
redirect_url = item['action'] | ||
if not redirect_url.lower().startswith(('../', 'javascript:', '++')): | ||
self.request.response.redirect(redirect_url) | ||
return u'' | ||
raise AssertionError("Should not get here") # pragma: no cover | ||
|
||
class LoginLogout(object): | ||
# Dummy implementation of zope.app.security.browser.auth.LoginLogout | ||
|
||
def __call__(self): | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
############################################################################# | ||
# | ||
# Copyright (c) 2017 Zope Foundation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (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. | ||
# | ||
############################################################################## | ||
|
||
import unittest | ||
from zope.app.component import testing | ||
|
||
from zope.component.interfaces import ISite | ||
|
||
class TestTesting(testing.PlacefulSetup, | ||
unittest.TestCase): | ||
|
||
def setUp(self): | ||
super(TestTesting, self).setUp(site=True) | ||
|
||
def test_is_site(self): | ||
self.assertTrue(ISite.providedBy(self.rootFolder)) | ||
|
||
def test_build_sample_folder(self): | ||
# We don't actually test the details of the layout, just some basics | ||
tree1 = testing.buildSampleFolderTree() | ||
self.assertIsNotNone(tree1) | ||
self.assertIsNot(tree1, testing.buildSampleFolderTree()) | ||
self.assertIn(u'folder1', tree1) | ||
|
||
def test_new_root(self): | ||
cur_root = self.rootFolder | ||
self.createRootFolder() | ||
self.assertIsNot(self.rootFolder, cur_root) | ||
|
||
def test_place_rebuilds_root(self): | ||
f1 = self.folder1 | ||
del self.rootFolder | ||
f2 = self.folder1 | ||
self.assertIsNot(f1, f2) | ||
|
||
def test_suite(): | ||
return unittest.defaultTestLoader.loadTestsFromName(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters