Skip to content

Commit

Permalink
env fixture removed
Browse files Browse the repository at this point in the history
  • Loading branch information
example Name committed Apr 20, 2022
1 parent 9587fee commit cf77123
Show file tree
Hide file tree
Showing 54 changed files with 1,816 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,3 @@ def _app():
def app(_app):
"""This fixture is the default application"""
return _app()


{{if auth}}
@pytest.fixture()
def env():
"""this is just a shorthand intended to be passed to extra_environ in webtest calls,
remote_user got as parameter will go into REMOTE_USER key,
other kwarguments are included in the returned dictionary"""
def _environ(remote_user, **kwargs):
r = {'REMOTE_USER': remote_user} if remote_user else {}
r.update(kwargs)
return r
return _environ
{{endif}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{if database}}from {{package}}.tests._conftest.models import obj{{endif}}
from {{package}}.tests._conftest.app import app, _app{{if auth}}, env{{endif}}
from {{package}}.tests._conftest.app import app, _app

# Fixtures defined in _conftest came from turbogears2, change them if you wish

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_data_json(app):
('/secc/some_where', 'manager', 200),
('/secc/some_where', 'editor', 403),
))
def test_secc_access(app, env, url, user, status):
app.get(url, extra_environ=env(user), status=status)
def test_secc_access(app, url, user, status):
app.get(url, extra_environ={'REMOTE_USER': user}), status=status)

{{endif}}
{{endif}}
Expand All @@ -72,8 +72,8 @@ def test_secc_access(app, env, url, user, status):
('/editor_user_only', 'manager', 403),
('/editor_user_only', 'editor', 200),
))
def test_page_access(app, env, url, user, status):
app.get(url, extra_environ=env(user), status=status)
def test_page_access(app, url, user, status):
app.get(url, extra_environ={'REMOTE_USER': user}, status=status)
{{endif}}

def test_error_document_500(app):
Expand Down
19 changes: 19 additions & 0 deletions test0/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# refer to https://coverage.readthedocs.io/en/latest/config.html
[run]
source = {{package}}

[report]
show_missing = True

# if you don't omit tests directory you have more chances of seeing two tests with same name
omit =
setup.py
migration/*
# tests/*

# fail test suite if coverage drops below 100% (if you uncomment it)
# this does not work for nosetests, set it in setup.cfg (min-cover-percentage)
# fail_under = 100

# Don’t include files in the report that are 100% covered files
skip_covered = True
4 changes: 4 additions & 0 deletions test0/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
recursive-include test0/public *
include test0/public/favicon.ico
recursive-include test0/i18n *
recursive-include test0/templates *
24 changes: 24 additions & 0 deletions test0/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This file is for you to describe the test0 application. Typically
you would include information such as the information below:

Installation and Setup
======================

Install ``test0`` using the setup.py script::

$ cd test0
$ python setup.py develop

Create the project database for any model classes defined::

$ gearbox setup-app

Start the paste http server::

$ gearbox serve

While developing you may want the server to reload after changes in package files (or its dependencies) are saved. This can be achieved easily by adding the --reload option::

$ gearbox serve --reload --debug

Then you are ready to go.
147 changes: 147 additions & 0 deletions test0/development.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#
# test0 - TurboGears 2 development environment configuration
#
# The %(here)s variable will be replaced with the parent directory of this file
#
# This file is for deployment specific config options -- other configuration
# that is always required for the app is done in the config directory,
# and generally should not be modified by end users.

[DEFAULT]
# WARNING: *THE LINE BELOW MUST BE FALSE ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
debug = true

# ERROR REPORTING BY EMAIL
# Uncomment to enable email error reporting, you probably want this
# on production to receive application crashes by email
#trace_errors.error_email = [email protected]
trace_errors.from_address = turbogears@localhost
trace_errors.smtp_server = localhost

# Uncomment if email server requires authentication
#trace_errors.smtp_use_tls = true
#trace_errors.smtp_username = unknown
#trace_errors.smtp_password = unknown

# Uncomment to enable additional context data for email error reporting
#trace_errors.dump_request = true
#trace_errors.dump_local_frames = true

# ERROR REPORTING TO SENTRY
# Uncomment to enable reporting errors to a Sentry server
#trace_errors.sentry_dsn = http://public:[email protected]/1

# REPORT SLOW REQUESTS
#trace_slowreqs.enable = true
#trace_slowreqs.interval = 25
#trace_slowreqs.exclude = /tw2/resources

[server:main]
use = egg:gearbox#wsgiref
host = 127.0.0.1
port = 8080

[app:main]
use = egg:test0

# Default application language, when available this will be
# used when none of the browser requested languages is available.
#i18n.lang = en

cache_dir = %(here)s/data
session.key = test0
session.secret = 9f80eb26-cf2a-4677-bd6f-6057256ae554

#By default session is store in cookies to avoid the overhead
#of having to manage a session storage. On production you might
#want to switch to a better session storage.
session.type = cookie
session.validate_key = 9f80eb26-cf2a-4677-bd6f-6057256ae554

# If you'd like to fine-tune the individual locations of the cache data dirs
# un-comment the desired settings here:
#cache.data_dir = %(here)s/data/cache

# Disable template autoreload to boost performances in production
# WARNING: if you want to deploy your application using a zipped egg
# (ie: if your application's setup.py defines zip-safe=True, then you
# MUST put "false" for the production environment because there will
# be no disk and real files to compare time with.
#auto_reload_templates = false

# Turn off static files serving from public/ directory
# this can be a speed boost if you have a proxy server already
# serving them for you.
#serve_static = false

#turn this setting to "min" if you would like tw to produce minified
#javascript files (if your library supports that)
toscawidgets.framework.resource_variant=debug

# pick the form for your database
# %(here) may include a ':' character on Windows environments; this can
# invalidate the URI when specifying a SQLite db via path name
ming.url = mongodb://localhost:27017/
ming.db = test0

# This line ensures that Genshi will render xhtml when sending the
# output. Change to html or xml, as desired.
templating.genshi.method = xhtml
templating.genshi.doctype = html5

# This might be required to make Genshi work on Python3.4
#templating.genshi.name_constant_patch = true

# the compiled template dir is a directory that must be readable and writable
# by your webserver. It will be used to store the resulting templates once
# compiled by the TemplateLookup system.
# During development you generally don't need this option since paste's HTTP
# server will have access to you development directories, but in production
# you'll most certainly want to have apache or nginx to write in a directory
# that does not contain any source code in any form for obvious security
# reasons. If disabled, None, False, or not writable, it will fall back
# to an in-memory cache.
templating.mako.compiled_templates_dir = %(here)s/data/templates

# Logging configuration
# Add additional loggers, handlers, formatters here
# Uses python's logging config file format
# http://docs.python.org/lib/logging-config-fileformat.html
[loggers]
keys = root, test0, auth

[handlers]
keys = console

[formatters]
keys = generic

# If you create additional loggers, add them as a key to [loggers]
[logger_root]
level = INFO
handlers = console

[logger_test0]
level = DEBUG
handlers =
qualname = test0
# A logger for authentication, identification and authorization
# this is repoze.who:
[logger_auth]
level = WARN
handlers =
qualname = auth

# If you create additional handlers, add them as a key to [handlers]
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

# If you create additional formatters, add them as a key to [formatters]
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
45 changes: 45 additions & 0 deletions test0/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[tool:pytest]
addopts = --cov=.

# Babel configuration
[compile_catalog]
domain = test0
directory = test0/i18n
statistics = true

[extract_messages]
add_comments = TRANSLATORS:
output_file = test0/i18n/test0.pot
width = 80
keywords = l_

[init_catalog]
domain = test0
input_file = test0/i18n/test0.pot
output_dir = test0/i18n

[update_catalog]
domain = test0
input_file = test0/i18n/test0.pot
output_dir = test0/i18n
previous = true

# Static files extraction for TW
[archive_tw_resources]
output = test0/public/toscawidgets/
distributions = test0
#yuicompressor = /home/someuser/bin/yuicompressor.jar
#compresslevel = 2
onepass = true

[archive_tw2_resources]
output = test0/public/tw2/
distributions = test0
force = true
#yuicompressor = /home/someuser/bin/yuicompressor.jar
#compresslevel = 2
onepass = true

[aliases]
# A handy alias to make a release to pypi
release = egg_info -RDb "" sdist bdist_egg register upload
86 changes: 86 additions & 0 deletions test0/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-

# Quickstarted Options:
#
# sqlalchemy: False
# auth: ming
# mako: False
#
#

# This is just a work-around for a Python2.7 issue causing
# interpreter crash at exit when trying to log an info message.
try:
import logging
import multiprocessing
except:
pass

import sys
py_version = sys.version_info[:2]

try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages

testpkgs = [
'WebTest >= 1.2.3',
'pytest',
'pytest-cov',
'pytest-randomly',
'coverage',
'gearbox'
]

install_requires = [
"TurboGears2 >= 2.4.3",
"Beaker >= 1.8.0",
"Kajiki >= 0.6.3",
"ming>=0.4.3",
"repoze.who",
"tw2.forms",
"tgext.admin >= 0.6.1",
"WebHelpers2"
]

if py_version != (3, 2):
# Babel not available on 3.2
install_requires.append("Babel")

setup(
name='test0',
version='0.1',
description='',
author='',
author_email='',
url='',
packages=find_packages(exclude=['ez_setup']),
install_requires=install_requires,
include_package_data=True,
tests_require=testpkgs,
extras_require={
'testing': testpkgs
},
package_data={'test0': [
'i18n/*/LC_MESSAGES/*.mo',
'templates/*/*',
'public/*/*'
]},
message_extractors={'test0': [
('**.py', 'python', None),
('templates/**.xhtml', 'kajiki', {'strip_text': False, 'extract_python': True}),
('public/**', 'ignore', None)
]},
entry_points={
'paste.app_factory': [
'main = test0.config.application:make_app'
],
'gearbox.plugins': [
'turbogears-devtools = tg.devtools'
]
},
zip_safe=False
)
Loading

0 comments on commit cf77123

Please sign in to comment.