diff options
Diffstat (limited to 'tests/pkgs')
57 files changed, 859 insertions, 0 deletions
diff --git a/tests/pkgs/__init__.py b/tests/pkgs/__init__.py new file mode 100644 index 000000000..5bb534f79 --- /dev/null +++ b/tests/pkgs/__init__.py @@ -0,0 +1 @@ +# package diff --git a/tests/pkgs/ccbugapp/__init__.py b/tests/pkgs/ccbugapp/__init__.py new file mode 100644 index 000000000..afe21d4e0 --- /dev/null +++ b/tests/pkgs/ccbugapp/__init__.py @@ -0,0 +1,16 @@ +from webob import Response + +def rdf_view(request): + """ """ + return Response('rdf') + +def juri_view(request): + """ """ + return Response('juri') + +def includeme(config): + config.add_route('rdf', 'licenses/:license_code/:license_version/rdf') + config.add_route('juri', + 'licenses/:license_code/:license_version/:jurisdiction') + config.add_view(rdf_view, route_name='rdf') + config.add_view(juri_view, route_name='juri') diff --git a/tests/pkgs/conflictapp/__init__.py b/tests/pkgs/conflictapp/__init__.py new file mode 100644 index 000000000..38116ab2f --- /dev/null +++ b/tests/pkgs/conflictapp/__init__.py @@ -0,0 +1,24 @@ +from pyramid.response import Response +from pyramid.authentication import AuthTktAuthenticationPolicy +from pyramid.authorization import ACLAuthorizationPolicy + +def aview(request): + return Response('a view') + +def routeview(request): + return Response('route view') + +def protectedview(request): + return Response('protected view') + +def includeme(config): + # purposely sorta-randomly ordered (route comes after view naming it, + # authz comes after views) + config.add_view(aview) + config.add_view(protectedview, name='protected', permission='view') + config.add_view(routeview, route_name='aroute') + config.add_route('aroute', '/route') + config.set_authentication_policy(AuthTktAuthenticationPolicy( + 'seekri1t', hashalg='sha512')) + config.set_authorization_policy(ACLAuthorizationPolicy()) + config.include('pyramid.tests.pkgs.conflictapp.included') diff --git a/tests/pkgs/conflictapp/included.py b/tests/pkgs/conflictapp/included.py new file mode 100644 index 000000000..0b76fb2bc --- /dev/null +++ b/tests/pkgs/conflictapp/included.py @@ -0,0 +1,6 @@ +from webob import Response + +def bview(request): return Response('b view') + +def includeme(config): + config.add_view(bview) diff --git a/tests/pkgs/defpermbugapp/__init__.py b/tests/pkgs/defpermbugapp/__init__.py new file mode 100644 index 000000000..032e8c626 --- /dev/null +++ b/tests/pkgs/defpermbugapp/__init__.py @@ -0,0 +1,26 @@ +from webob import Response +from pyramid.security import NO_PERMISSION_REQUIRED +from pyramid.view import view_config + +@view_config(name='x') +def x_view(request): # pragma: no cover + return Response('this is private!') + +@view_config(name='y', permission='private2') +def y_view(request): # pragma: no cover + return Response('this is private too!') + +@view_config(name='z', permission=NO_PERMISSION_REQUIRED) +def z_view(request): + return Response('this is public') + +def includeme(config): + from pyramid.authorization import ACLAuthorizationPolicy + from pyramid.authentication import AuthTktAuthenticationPolicy + authn_policy = AuthTktAuthenticationPolicy('seekt1t', hashalg='sha512') + authz_policy = ACLAuthorizationPolicy() + config.scan('pyramid.tests.pkgs.defpermbugapp') + config._set_authentication_policy(authn_policy) + config._set_authorization_policy(authz_policy) + config.set_default_permission('private') + diff --git a/tests/pkgs/eventonly/__init__.py b/tests/pkgs/eventonly/__init__.py new file mode 100644 index 000000000..7ae93ada6 --- /dev/null +++ b/tests/pkgs/eventonly/__init__.py @@ -0,0 +1,64 @@ +from pyramid.view import view_config +from pyramid.events import subscriber + +class Yup(object): + def __init__(self, val, config): + self.val = val + + def text(self): + return 'path_startswith = %s' % (self.val,) + + phash = text + + def __call__(self, event): + return getattr(event.response, 'yup', False) + +class Foo(object): + def __init__(self, response): + self.response = response + +class Bar(object): + pass + +@subscriber(Foo) +def foo(event): + event.response.text += 'foo ' + +@subscriber(Foo, yup=True) +def fooyup(event): + event.response.text += 'fooyup ' + +@subscriber([Foo, Bar]) +def foobar(event): + event.response.text += 'foobar ' + +@subscriber([Foo, Bar]) +def foobar2(event, context): + event.response.text += 'foobar2 ' + +@subscriber([Foo, Bar], yup=True) +def foobaryup(event): + event.response.text += 'foobaryup ' + +@subscriber([Foo, Bar], yup=True) +def foobaryup2(event, context): + event.response.text += 'foobaryup2 ' + +@view_config(name='sendfoo') +def sendfoo(request): + response = request.response + response.yup = True + request.registry.notify(Foo(response)) + return response + +@view_config(name='sendfoobar') +def sendfoobar(request): + response = request.response + response.yup = True + request.registry.notify(Foo(response), Bar()) + return response + +def includeme(config): + config.add_subscriber_predicate('yup', Yup) + config.scan('pyramid.tests.pkgs.eventonly') + diff --git a/tests/pkgs/exceptionviewapp/__init__.py b/tests/pkgs/exceptionviewapp/__init__.py new file mode 100644 index 000000000..ffc1b47c6 --- /dev/null +++ b/tests/pkgs/exceptionviewapp/__init__.py @@ -0,0 +1,31 @@ +from pyramid.httpexceptions import HTTPException + +def includeme(config): + config.add_route('route_raise_exception', 'route_raise_exception') + config.add_route('route_raise_httpexception', 'route_raise_httpexception') + config.add_route('route_raise_exception2', 'route_raise_exception2', + factory='.models.route_factory') + config.add_route('route_raise_exception3', 'route_raise_exception3', + factory='.models.route_factory2') + config.add_route('route_raise_exception4', 'route_raise_exception4') + config.add_view('.views.maybe') + config.add_view('.views.no', context='.models.NotAnException') + config.add_view('.views.yes', context=".models.AnException") + config.add_view('.views.raise_exception', name='raise_exception') + config.add_view('.views.raise_exception', + route_name='route_raise_exception') + config.add_view('.views.raise_exception', + route_name='route_raise_exception2') + config.add_view('.views.raise_exception', + route_name='route_raise_exception3') + config.add_view('.views.whoa', context='.models.AnException', + route_name='route_raise_exception3') + config.add_view('.views.raise_exception', + route_name='route_raise_exception4') + config.add_view('.views.whoa', context='.models.AnException', + route_name='route_raise_exception4') + config.add_view('.views.raise_httpexception', + route_name='route_raise_httpexception') + config.add_view('.views.catch_httpexception', context=HTTPException) + + diff --git a/tests/pkgs/exceptionviewapp/models.py b/tests/pkgs/exceptionviewapp/models.py new file mode 100644 index 000000000..fe407badc --- /dev/null +++ b/tests/pkgs/exceptionviewapp/models.py @@ -0,0 +1,18 @@ + +class NotAnException(object): + pass + +class AnException(Exception): + pass + +class RouteContext(object): + pass + +class RouteContext2(object): + pass + +def route_factory(*arg): + return RouteContext() + +def route_factory2(*arg): + return RouteContext2() diff --git a/tests/pkgs/exceptionviewapp/views.py b/tests/pkgs/exceptionviewapp/views.py new file mode 100644 index 000000000..4953056bc --- /dev/null +++ b/tests/pkgs/exceptionviewapp/views.py @@ -0,0 +1,24 @@ +from webob import Response +from .models import AnException +from pyramid.httpexceptions import HTTPBadRequest + +def no(request): + return Response('no') + +def yes(request): + return Response('yes') + +def maybe(request): + return Response('maybe') + +def whoa(request): + return Response('whoa') + +def raise_exception(request): + raise AnException() + +def raise_httpexception(request): + raise HTTPBadRequest + +def catch_httpexception(request): + return Response('caught') diff --git a/tests/pkgs/fixtureapp/__init__.py b/tests/pkgs/fixtureapp/__init__.py new file mode 100644 index 000000000..27063aae2 --- /dev/null +++ b/tests/pkgs/fixtureapp/__init__.py @@ -0,0 +1,12 @@ +def includeme(config): + config.add_view('.views.fixture_view') + config.add_view('.views.exception_view', context=RuntimeError) + config.add_view('.views.protected_view', name='protected.html') + config.add_view('.views.erroneous_view', name='error.html') + config.add_view('.views.fixture_view', name='dummyskin.html', + request_type='.views.IDummy') + from .models import fixture, IFixture + config.registry.registerUtility(fixture, IFixture) + config.add_view('.views.fixture_view', name='another.html') + + diff --git a/tests/pkgs/fixtureapp/models.py b/tests/pkgs/fixtureapp/models.py new file mode 100644 index 000000000..d80d14bb3 --- /dev/null +++ b/tests/pkgs/fixtureapp/models.py @@ -0,0 +1,8 @@ +from zope.interface import Interface + +class IFixture(Interface): + pass + +def fixture(): + """ """ + diff --git a/tests/pkgs/fixtureapp/subpackage/__init__.py b/tests/pkgs/fixtureapp/subpackage/__init__.py new file mode 100644 index 000000000..d3173e636 --- /dev/null +++ b/tests/pkgs/fixtureapp/subpackage/__init__.py @@ -0,0 +1 @@ +#package diff --git a/tests/pkgs/fixtureapp/views.py b/tests/pkgs/fixtureapp/views.py new file mode 100644 index 000000000..cbfc5a574 --- /dev/null +++ b/tests/pkgs/fixtureapp/views.py @@ -0,0 +1,22 @@ +from zope.interface import Interface +from webob import Response +from pyramid.httpexceptions import HTTPForbidden + +def fixture_view(context, request): + """ """ + return Response('fixture') + +def erroneous_view(context, request): + """ """ + raise RuntimeError() + +def exception_view(context, request): + """ """ + return Response('supressed') + +def protected_view(context, request): + """ """ + raise HTTPForbidden() + +class IDummy(Interface): + pass diff --git a/tests/pkgs/forbiddenapp/__init__.py b/tests/pkgs/forbiddenapp/__init__.py new file mode 100644 index 000000000..c378126fc --- /dev/null +++ b/tests/pkgs/forbiddenapp/__init__.py @@ -0,0 +1,24 @@ +from webob import Response +from pyramid.httpexceptions import HTTPForbidden +from pyramid.compat import bytes_ + +def x_view(request): # pragma: no cover + return Response('this is private!') + +def forbidden_view(context, request): + msg = context.message + result = context.result + message = msg + '\n' + str(result) + resp = HTTPForbidden() + resp.body = bytes_(message) + return resp + +def includeme(config): + from pyramid.authentication import AuthTktAuthenticationPolicy + from pyramid.authorization import ACLAuthorizationPolicy + authn_policy = AuthTktAuthenticationPolicy('seekr1t', hashalg='sha512') + authz_policy = ACLAuthorizationPolicy() + config._set_authentication_policy(authn_policy) + config._set_authorization_policy(authz_policy) + config.add_view(x_view, name='x', permission='private') + config.add_view(forbidden_view, context=HTTPForbidden) diff --git a/tests/pkgs/forbiddenview/__init__.py b/tests/pkgs/forbiddenview/__init__.py new file mode 100644 index 000000000..45fb8380b --- /dev/null +++ b/tests/pkgs/forbiddenview/__init__.py @@ -0,0 +1,31 @@ +from pyramid.view import forbidden_view_config, view_config +from pyramid.response import Response +from pyramid.authentication import AuthTktAuthenticationPolicy +from pyramid.authorization import ACLAuthorizationPolicy + +@forbidden_view_config(route_name='foo') +def foo_forbidden(request): # pragma: no cover + return Response('foo_forbidden') + +@forbidden_view_config() +def forbidden(request): + return Response('generic_forbidden') + +@view_config(route_name='foo') +def foo(request): # pragma: no cover + return Response('OK foo') + +@view_config(route_name='bar') +def bar(request): # pragma: no cover + return Response('OK bar') + +def includeme(config): + authn_policy = AuthTktAuthenticationPolicy('seekri1', hashalg='sha512') + authz_policy = ACLAuthorizationPolicy() + config.set_authentication_policy(authn_policy) + config.set_authorization_policy(authz_policy) + config.set_default_permission('a') + config.add_route('foo', '/foo') + config.add_route('bar', '/bar') + config.scan('pyramid.tests.pkgs.forbiddenview') + diff --git a/tests/pkgs/hybridapp/__init__.py b/tests/pkgs/hybridapp/__init__.py new file mode 100644 index 000000000..1cc2dde83 --- /dev/null +++ b/tests/pkgs/hybridapp/__init__.py @@ -0,0 +1,39 @@ +def includeme(config): + # <!-- we want this view to "win" --> + config.add_route('route', 'abc') + config.add_view('.views.route_view', route_name='route') + # <!-- .. even though this one has a more specific context --> + config.add_view('.views.global_view', + context='pyramid.traversal.DefaultRootFactory') + config.add_view('.views.global2_view', + context='pyramid.traversal.DefaultRootFactory', + name='global2') + config.add_route('route2', 'def') + # <!-- we want this view to win for route2 even though global view with + # context is more specific --> + config.add_view('.views.route2_view', route_name='route2') + + # <!-- the global view should be found for this route --> + config.add_route('route3', 'ghi', use_global_views=True) + # <!-- the global view should not be found for this route --> + config.add_route('route4', 'jkl') + # <!-- the global view should not be found for this route (/global2) --> + config.add_route('route5', 'mno/*traverse') + # <!-- the global view should be found for this route (/global2) --> + config.add_route('route6', 'pqr/*traverse', use_global_views=True) + config.add_route('route7', 'error') + config.add_view('.views.erroneous_view', route_name='route7') + config.add_route('route8', 'error2') + config.add_view('.views.erroneous_view', route_name='route8') + # <!-- we want this view to "win" for route7 as exception view --> + config.add_view('.views.exception_view', context=RuntimeError) + # <!-- we want this view to "win" for route8 as exception view--> + config.add_view('.views.exception2_view', context=RuntimeError, + route_name='route8') + config.add_route('route9', 'error_sub') + config.add_view('.views.erroneous_sub_view', route_name='route9') + # <!-- we want this view to "win" for route9 as exception view... --> + config.add_view('.views.exception2_view', context='.views.SuperException', + route_name='route9') + # <!-- ...even if we have more context-specialized view for exception --> + config.add_view('.views.exception_view', context='.views.SubException') diff --git a/tests/pkgs/hybridapp/views.py b/tests/pkgs/hybridapp/views.py new file mode 100644 index 000000000..135ef8290 --- /dev/null +++ b/tests/pkgs/hybridapp/views.py @@ -0,0 +1,39 @@ +from webob import Response + +def route_view(request): + """ """ + return Response('route') + +def global_view(request): + """ """ + return Response('global') + +def global2_view(request): + """ """ + return Response('global2') + +def route2_view(request): + """ """ + return Response('route2') + +def exception_view(request): + """ """ + return Response('supressed') + +def exception2_view(request): + """ """ + return Response('supressed2') + +def erroneous_view(request): + """ """ + raise RuntimeError() + +def erroneous_sub_view(request): + """ """ + raise SubException() + +class SuperException(Exception): + """ """ + +class SubException(SuperException): + """ """ diff --git a/tests/pkgs/includeapp1/__init__.py b/tests/pkgs/includeapp1/__init__.py new file mode 100644 index 000000000..eaeeb7ef6 --- /dev/null +++ b/tests/pkgs/includeapp1/__init__.py @@ -0,0 +1 @@ +# include app diff --git a/tests/pkgs/includeapp1/root.py b/tests/pkgs/includeapp1/root.py new file mode 100644 index 000000000..f56203cfa --- /dev/null +++ b/tests/pkgs/includeapp1/root.py @@ -0,0 +1,10 @@ +from pyramid.response import Response + +def aview(request): + return Response('root') + +def configure(config): + config.add_view(aview) + config.include('pyramid.tests.pkgs.includeapp1.two.configure') + config.commit() + diff --git a/tests/pkgs/includeapp1/three.py b/tests/pkgs/includeapp1/three.py new file mode 100644 index 000000000..e7131bcf5 --- /dev/null +++ b/tests/pkgs/includeapp1/three.py @@ -0,0 +1,10 @@ +from pyramid.response import Response + +def aview(request): + return Response('three') + +def configure(config): + config.add_view(aview, name='three') + config.include('pyramid.tests.pkgs.includeapp1.two.configure') # should not cycle + config.add_view(aview) # will be overridden by root when resolved + diff --git a/tests/pkgs/includeapp1/two.py b/tests/pkgs/includeapp1/two.py new file mode 100644 index 000000000..99b0f883a --- /dev/null +++ b/tests/pkgs/includeapp1/two.py @@ -0,0 +1,9 @@ +from pyramid.response import Response + +def aview(request): + return Response('two') + +def configure(config): + config.add_view(aview, name='two') + config.include('pyramid.tests.pkgs.includeapp1.three.configure') + config.add_view(aview) # will be overridden by root when resolved diff --git a/tests/pkgs/localeapp/__init__.py b/tests/pkgs/localeapp/__init__.py new file mode 100644 index 000000000..1a35cdb4a --- /dev/null +++ b/tests/pkgs/localeapp/__init__.py @@ -0,0 +1 @@ +# a file diff --git a/tests/pkgs/localeapp/locale/GARBAGE b/tests/pkgs/localeapp/locale/GARBAGE new file mode 100644 index 000000000..032c55584 --- /dev/null +++ b/tests/pkgs/localeapp/locale/GARBAGE @@ -0,0 +1 @@ +Garbage file. diff --git a/tests/pkgs/localeapp/locale/be/LC_MESSAGES b/tests/pkgs/localeapp/locale/be/LC_MESSAGES new file mode 100644 index 000000000..909cf6a3b --- /dev/null +++ b/tests/pkgs/localeapp/locale/be/LC_MESSAGES @@ -0,0 +1 @@ +busted. diff --git a/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale/de/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..e3b2b0881 --- /dev/null +++ b/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..be055bed9 --- /dev/null +++ b/tests/pkgs/localeapp/locale/de_DE/LC_MESSAGES/deformsite.po @@ -0,0 +1,26 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "different" diff --git a/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale/en/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/localeapp/locale2/GARBAGE b/tests/pkgs/localeapp/locale2/GARBAGE new file mode 100644 index 000000000..032c55584 --- /dev/null +++ b/tests/pkgs/localeapp/locale2/GARBAGE @@ -0,0 +1 @@ +Garbage file. diff --git a/tests/pkgs/localeapp/locale2/be/LC_MESSAGES b/tests/pkgs/localeapp/locale2/be/LC_MESSAGES new file mode 100644 index 000000000..909cf6a3b --- /dev/null +++ b/tests/pkgs/localeapp/locale2/be/LC_MESSAGES @@ -0,0 +1 @@ +busted. diff --git a/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale2/de/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale2/en/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/localeapp/locale3/GARBAGE b/tests/pkgs/localeapp/locale3/GARBAGE new file mode 100644 index 000000000..032c55584 --- /dev/null +++ b/tests/pkgs/localeapp/locale3/GARBAGE @@ -0,0 +1 @@ +Garbage file. diff --git a/tests/pkgs/localeapp/locale3/be/LC_MESSAGES b/tests/pkgs/localeapp/locale3/be/LC_MESSAGES new file mode 100644 index 000000000..909cf6a3b --- /dev/null +++ b/tests/pkgs/localeapp/locale3/be/LC_MESSAGES @@ -0,0 +1 @@ +busted. diff --git a/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale3/de/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.mo b/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.mo Binary files differnew file mode 100644 index 000000000..2924a5eb5 --- /dev/null +++ b/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.mo diff --git a/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.po b/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.po new file mode 100644 index 000000000..17f87bc19 --- /dev/null +++ b/tests/pkgs/localeapp/locale3/en/LC_MESSAGES/deformsite.po @@ -0,0 +1,31 @@ +# German translations for deformsite. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the deformsite project. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: deformsite 0.0\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-04-22 14:17+0400\n" +"PO-Revision-Date: 2010-04-22 14:17-0400\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: de <LL@li.org>\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: deformsite/__init__.py:458 +msgid "Approve" +msgstr "Genehmigen" + +#: deformsite/__init__.py:459 +msgid "Show approval" +msgstr "Zeigen Genehmigung" + +#: deformsite/__init__.py:466 +msgid "Submit" +msgstr "Beugen" + diff --git a/tests/pkgs/notfoundview/__init__.py b/tests/pkgs/notfoundview/__init__.py new file mode 100644 index 000000000..ae148ea8c --- /dev/null +++ b/tests/pkgs/notfoundview/__init__.py @@ -0,0 +1,30 @@ +from pyramid.view import notfound_view_config, view_config +from pyramid.response import Response + +@notfound_view_config(route_name='foo', append_slash=True) +def foo_notfound(request): # pragma: no cover + return Response('foo_notfound') + +@notfound_view_config(route_name='baz') +def baz_notfound(request): + return Response('baz_notfound') + +@notfound_view_config(append_slash=True) +def notfound(request): + return Response('generic_notfound') + +@view_config(route_name='bar') +def bar(request): + return Response('OK bar') + +@view_config(route_name='foo2') +def foo2(request): + return Response('OK foo2') + +def includeme(config): + config.add_route('foo', '/foo') + config.add_route('foo2', '/foo/') + config.add_route('bar', '/bar/') + config.add_route('baz', '/baz') + config.scan('pyramid.tests.pkgs.notfoundview') + diff --git a/tests/pkgs/permbugapp/__init__.py b/tests/pkgs/permbugapp/__init__.py new file mode 100644 index 000000000..4868427a5 --- /dev/null +++ b/tests/pkgs/permbugapp/__init__.py @@ -0,0 +1,22 @@ +from pyramid.compat import escape +from pyramid.security import view_execution_permitted +from pyramid.response import Response + +def x_view(request): # pragma: no cover + return Response('this is private!') + +def test(context, request): + # should return false + msg = 'Allow ./x? %s' % repr(view_execution_permitted( + context, request, 'x')) + return Response(escape(msg)) + +def includeme(config): + from pyramid.authentication import AuthTktAuthenticationPolicy + from pyramid.authorization import ACLAuthorizationPolicy + authn_policy = AuthTktAuthenticationPolicy('seekt1t', hashalg='sha512') + authz_policy = ACLAuthorizationPolicy() + config.set_authentication_policy(authn_policy) + config.set_authorization_policy(authz_policy) + config.add_view(test, name='test') + config.add_view(x_view, name='x', permission='private') diff --git a/tests/pkgs/rendererscanapp/__init__.py b/tests/pkgs/rendererscanapp/__init__.py new file mode 100644 index 000000000..f3276a063 --- /dev/null +++ b/tests/pkgs/rendererscanapp/__init__.py @@ -0,0 +1,9 @@ +from pyramid.view import view_config + +@view_config(name='one', renderer='json') +def one(request): + return {'name':'One!'} + +def includeme(config): + config.scan() + diff --git a/tests/pkgs/rendererscanapp/two/__init__.py b/tests/pkgs/rendererscanapp/two/__init__.py new file mode 100644 index 000000000..6f575dd83 --- /dev/null +++ b/tests/pkgs/rendererscanapp/two/__init__.py @@ -0,0 +1,6 @@ +from pyramid.view import view_config + +@view_config(name='two', renderer='json') +def two(request): + return {'nameagain':'Two!'} + diff --git a/tests/pkgs/restbugapp/__init__.py b/tests/pkgs/restbugapp/__init__.py new file mode 100644 index 000000000..9ad79e32e --- /dev/null +++ b/tests/pkgs/restbugapp/__init__.py @@ -0,0 +1,15 @@ +def includeme(config): + config.add_route('gameactions_pet_get_pets', '/pet', + request_method='GET') + config.add_route('gameactions_pet_care_for_pet', '/pet', + request_method='POST') + config.add_view('.views.PetRESTView', + route_name='gameactions_pet_get_pets', + attr='GET', + permission='view', + renderer='json') + config.add_view('.views.PetRESTView', + route_name='gameactions_pet_care_for_pet', + attr='POST', + permission='view', + renderer='json') diff --git a/tests/pkgs/restbugapp/views.py b/tests/pkgs/restbugapp/views.py new file mode 100644 index 000000000..2ace59fa9 --- /dev/null +++ b/tests/pkgs/restbugapp/views.py @@ -0,0 +1,15 @@ +from pyramid.response import Response + +class BaseRESTView(object): + def __init__(self, context, request): + self.context = context + self.request = request + +class PetRESTView(BaseRESTView): + """ REST Controller to control action of an avatar """ + def __init__(self, context, request): + super(PetRESTView, self).__init__(context, request) + + def GET(self): + return Response('gotten') + diff --git a/tests/pkgs/static_abspath/__init__.py b/tests/pkgs/static_abspath/__init__.py new file mode 100644 index 000000000..812cca467 --- /dev/null +++ b/tests/pkgs/static_abspath/__init__.py @@ -0,0 +1,7 @@ +import os + +def includeme(config): + here = here = os.path.dirname(__file__) + fixtures = os.path.normpath(os.path.join(here, '..', '..', 'fixtures')) + config.add_static_view('/', fixtures) + diff --git a/tests/pkgs/static_assetspec/__init__.py b/tests/pkgs/static_assetspec/__init__.py new file mode 100644 index 000000000..cd6195397 --- /dev/null +++ b/tests/pkgs/static_assetspec/__init__.py @@ -0,0 +1,3 @@ +def includeme(config): + config.add_static_view('/', 'pyramid.tests:fixtures') + diff --git a/tests/pkgs/static_routeprefix/__init__.py b/tests/pkgs/static_routeprefix/__init__.py new file mode 100644 index 000000000..9b539380a --- /dev/null +++ b/tests/pkgs/static_routeprefix/__init__.py @@ -0,0 +1,7 @@ +def includeme(config): + config.add_static_view('/static', 'pyramid.tests:fixtures') + config.include(includeme2, route_prefix='/prefix') + +def includeme2(config): + config.add_static_view('/static', 'pyramid.tests:fixtures/static') + diff --git a/tests/pkgs/staticpermapp/__init__.py b/tests/pkgs/staticpermapp/__init__.py new file mode 100644 index 000000000..cc690d937 --- /dev/null +++ b/tests/pkgs/staticpermapp/__init__.py @@ -0,0 +1,25 @@ +class RootFactory(object): + __acl__ = [('Allow', 'fred', 'view')] + def __init__(self, request): + pass + +class LocalRootFactory(object): + __acl__ = [('Allow', 'bob', 'view')] + def __init__(self, request): + pass + + +def includeme(config): + from pyramid.authentication import RemoteUserAuthenticationPolicy + from pyramid.authorization import ACLAuthorizationPolicy + authn_policy = RemoteUserAuthenticationPolicy() + authz_policy = ACLAuthorizationPolicy() + config._set_authentication_policy(authn_policy) + config._set_authorization_policy(authz_policy) + config.add_static_view('allowed', 'pyramid.tests:fixtures/static/') + config.add_static_view('protected', 'pyramid.tests:fixtures/static/', + permission='view') + config.add_static_view('factory_protected', + 'pyramid.tests:fixtures/static/', + permission='view', + factory=LocalRootFactory) diff --git a/tests/pkgs/subrequestapp/__init__.py b/tests/pkgs/subrequestapp/__init__.py new file mode 100644 index 000000000..e4b1d386a --- /dev/null +++ b/tests/pkgs/subrequestapp/__init__.py @@ -0,0 +1,52 @@ +from pyramid.config import Configurator +from pyramid.request import Request + +def view_one(request): + subreq = Request.blank('/view_two') + response = request.invoke_subrequest(subreq, use_tweens=False) + return response + +def view_two(request): + # check that request.foo is valid for a subrequest + return 'This came from view_two, foo=%s' % (request.foo,) + +def view_three(request): + subreq = Request.blank('/view_four') + try: + return request.invoke_subrequest(subreq, use_tweens=True) + except: # pragma: no cover + request.response.body = b'Value error raised' + return request.response + +def view_four(request): + raise ValueError('foo') + +def view_five(request): + subreq = Request.blank('/view_four') + try: + return request.invoke_subrequest(subreq, use_tweens=False) + except ValueError: + request.response.body = b'Value error raised' + return request.response + +def excview(request): + request.response.status_int = 500 + request.response.body = b'Bad stuff happened' + return request.response + +def main(): + config = Configurator() + config.add_route('one', '/view_one') + config.add_route('two', '/view_two') + config.add_route('three', '/view_three') + config.add_route('four', '/view_four') + config.add_route('five', '/view_five') + config.add_view(excview, context=Exception) + config.add_view(view_one, route_name='one') + config.add_view(view_two, route_name='two', renderer='string') + config.add_view(view_three, route_name='three') + config.add_view(view_four, route_name='four') + config.add_view(view_five, route_name='five') + config.add_request_method(lambda r: 'bar', 'foo', property=True) + return config + diff --git a/tests/pkgs/viewdecoratorapp/__init__.py b/tests/pkgs/viewdecoratorapp/__init__.py new file mode 100644 index 000000000..5fa98062a --- /dev/null +++ b/tests/pkgs/viewdecoratorapp/__init__.py @@ -0,0 +1,3 @@ +def includeme(config): + config.scan('pyramid.tests.pkgs.viewdecoratorapp') + diff --git a/tests/pkgs/viewdecoratorapp/views/__init__.py b/tests/pkgs/viewdecoratorapp/views/__init__.py new file mode 100644 index 000000000..5bb534f79 --- /dev/null +++ b/tests/pkgs/viewdecoratorapp/views/__init__.py @@ -0,0 +1 @@ +# package diff --git a/tests/pkgs/viewdecoratorapp/views/views.py b/tests/pkgs/viewdecoratorapp/views/views.py new file mode 100644 index 000000000..18ec78847 --- /dev/null +++ b/tests/pkgs/viewdecoratorapp/views/views.py @@ -0,0 +1,12 @@ +from pyramid.view import view_config + +@view_config(renderer='json', name='first') +def first(request): + return {'result':'OK1'} + +@view_config( + renderer='json', + name='second') +def second(request): + return {'result':'OK2'} + diff --git a/tests/pkgs/wsgiapp2app/__init__.py b/tests/pkgs/wsgiapp2app/__init__.py new file mode 100644 index 000000000..e2024198e --- /dev/null +++ b/tests/pkgs/wsgiapp2app/__init__.py @@ -0,0 +1,17 @@ +from pyramid.view import view_config +from pyramid.wsgi import wsgiapp2 + +@view_config(name='hello', renderer='string') +@wsgiapp2 +def hello(environ, start_response): + assert environ['PATH_INFO'] == '/' + assert environ['SCRIPT_NAME'] == '/hello' + response_headers = [('Content-Type', 'text/plain')] + start_response('200 OK', response_headers) + return [b'Hello!'] + +def main(): + from pyramid.config import Configurator + c = Configurator() + c.scan() + return c |
