diff options
| -rw-r--r-- | pyramid/tests/test_asset.py | 26 | ||||
| -rw-r--r-- | pyramid/tests/test_config.py | 28 |
2 files changed, 54 insertions, 0 deletions
diff --git a/pyramid/tests/test_asset.py b/pyramid/tests/test_asset.py index ec45eb638..494838d59 100644 --- a/pyramid/tests/test_asset.py +++ b/pyramid/tests/test_asset.py @@ -422,6 +422,32 @@ class Test_abspath_from_asset_spec(unittest.TestCase): result = self._callFUT('abc', 'pyramid.tests') self.assertEqual(result, os.path.join(path, 'abc')) +class Test_asset_spec_from_abspath(unittest.TestCase): + def _callFUT(self, abspath, package): + from pyramid.asset import asset_spec_from_abspath + return asset_spec_from_abspath(abspath, package) + + def test_package_name_is_main(self): + pkg = DummyPackage('__main__') + result = self._callFUT('abspath', pkg) + self.assertEqual(result, 'abspath') + + def test_abspath_startswith_package_path(self): + import os + abspath = os.path.dirname(__file__) + '/fixtureapp' + pkg = DummyPackage('pyramid.tests') + pkg.__file__ = 'file' + result = self._callFUT(abspath, pkg) + self.assertEqual(result, 'pyramid:fixtureapp') + + def test_abspath_doesnt_startwith_package_path(self): + import os + abspath = os.path.dirname(__file__) + pkg = DummyPackage('pyramid.tests') + result = self._callFUT(abspath, pkg) + self.assertEqual(result, abspath) + + class DummyOverride: def __init__(self, result): self.result = result diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 7135501b9..346c2e6f0 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -2274,6 +2274,20 @@ class ConfiguratorTests(unittest.TestCase): result = view(None, request) self.assertEqual(result, ('abc', request)) + def test_set_notfound_view_with_renderer(self): + from zope.interface import implementedBy + from pyramid.interfaces import IRequest + from pyramid.exceptions import NotFound + config = self._makeOne(autocommit=True) + view = lambda *arg: {} + config.set_notfound_view(view, + renderer='pyramid.tests:fixtures/minimal.pt') + request = self._makeRequest(config) + view = self._getViewCallable(config, ctx_iface=implementedBy(NotFound), + request_iface=IRequest) + result = view(None, request) + self.failUnless('div' in result.body) + def test_set_forbidden_view(self): from zope.interface import implementedBy from pyramid.interfaces import IRequest @@ -2301,6 +2315,20 @@ class ConfiguratorTests(unittest.TestCase): result = view(None, request) self.assertEqual(result, ('abc', request)) + def test_set_forbidden_view_with_renderer(self): + from zope.interface import implementedBy + from pyramid.interfaces import IRequest + from pyramid.exceptions import Forbidden + config = self._makeOne(autocommit=True) + view = lambda *arg: {} + config.set_forbidden_view(view, + renderer='pyramid.tests:fixtures/minimal.pt') + request = self._makeRequest(config) + view = self._getViewCallable(config, ctx_iface=implementedBy(Forbidden), + request_iface=IRequest) + result = view(None, request) + self.failUnless('div' in result.body) + def test__set_authentication_policy(self): from pyramid.interfaces import IAuthenticationPolicy config = self._makeOne(autocommit=True) |
