本文整理汇总了Python中pyramid.testing.setUp函数的典型用法代码示例。如果您正苦于以下问题:Python setUp函数的具体用法?Python setUp怎么用?Python setUp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setUp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_user_edit_view_no_matchdict
def test_user_edit_view_no_matchdict(self):
"""
user edit view -- matchdict test & redirect
if matchdict is invalid, expect redirect
"""
from c3sar.views.user import user_edit
request = testing.DummyRequest()
self.config = testing.setUp(request=request)
_registerRoutes(self.config)
instance = self._makeUser()
self.dbsession.add(instance)
self.dbsession.flush()
result = user_edit(request)
# test: a redirect is triggered iff no matchdict
self.assertTrue(isinstance(result, HTTPFound), 'no redirect seen')
self.assertTrue('not_found' in str(result.headers),
'not redirecting to not_found')
# and one more with faulty matchdict
request = testing.DummyRequest()
self.config = testing.setUp(request=request)
_registerRoutes(self.config)
request.matchdict['user_id'] = 'foo'
result = user_edit(request)
# test: a redirect is triggered iff matchdict faulty
self.assertTrue(isinstance(result, HTTPFound), 'no redirect seen')
self.assertTrue('not_found' in str(result.headers),
'not redirecting to not_found')
开发者ID:AnneGilles,项目名称:c3sar,代码行数:30,代码来源:test_user_views.py
示例2: setUp
def setUp(self):
self.config = testing.setUp()
self.regis = Registry()
self.regis.register_provider(trees)
config = testing.setUp()
config.add_route('home', 'foo')
config.add_settings(settings)
开发者ID:JDeVos,项目名称:atramhasis,代码行数:7,代码来源:test_views.py
示例3: setUp
def setUp(self):
import tempfile
import os.path
self.tmpdir = tempfile.mkdtemp()
dbpath = os.path.join( self.tmpdir, 'test.db')
uri = 'file://' + dbpath
settings = {'zodbconn.uri': uri,
'substanced.secret': 'sosecret',
'substanced.initial_login': 'admin',
'substanced.initial_password': 'admin',
'pyramid.includes': [
'substanced',
'pyramid_chameleon',
'pyramid_layout',
'pyramid_mailer.testing', # have to be after substanced to override the mailer
'pyramid_tm',
'dace',
'pontus',
]}
app = main({}, **settings)
self.db = app.registry._zodb_databases['']
request = DummyRequest()
testing.setUp(registry=app.registry, request=request)
self.app = root_factory(request)
request.root = self.app
from webtest import TestApp
self.testapp = TestApp(app)
self.request = request
import time; time.sleep(2)
开发者ID:ecreall,项目名称:pontus,代码行数:30,代码来源:testing.py
示例4: setUp
def setUp(self):
testing.setUp()
self.config = testing.setUp()
from webhook import main
app = main.main({})
from webtest import TestApp
self.testapp = TestApp(app)
开发者ID:opendesk,项目名称:github-webhook,代码行数:7,代码来源:webhook_tests.py
示例5: setUp
def setUp(self):
from pyramid.paster import get_app
from bookie.tests import BOOKIE_TEST_INI
app = get_app(BOOKIE_TEST_INI, 'main')
from webtest import TestApp
self.testapp = TestApp(app)
testing.setUp()
开发者ID:akn,项目名称:Bookie,代码行数:7,代码来源:test_export.py
示例6: setUp
def setUp(self):
print ('TEST setup')
self.config = testing.setUp()
from sqlalchemy import create_engine
engine = create_engine(settings['sqlalchemy.url'])
from .Models import (
Base, ObservationDynProp,
ProtocoleType,
ProtocoleType_ObservationDynProp,
ObservationDynPropValue,
Observation
)
self.engine = create_engine(settings['sqlalchemy.url'])
self.config = testing.setUp()
# self.engine = create_engine(settings['sqlalchemy.url'])
self.connection = self.engine.connect()
self.trans = self.connection.begin()
DBSession.configure(bind=self.connection)
self.DBSession = DBSession()
Base.session = self.DBSession
开发者ID:JWepi,项目名称:NsPortal,代码行数:25,代码来源:tests.py
示例7: test_cookie
def test_cookie(self):
settings = {'pyramid.includes': '\n pyramid_kvs.testing',
'kvs.session': """{"kvs": "mock",
"key_name": "SessionId",
"session_type": "cookie",
"codec": "json",
"key_prefix": "cookie::",
"ttl": 20}"""}
testing.setUp(settings=settings)
factory = SessionFactory(settings)
MockCache.cached_data = {
b'cookie::chocolate': '{"anotherkey": "another val"}'
}
self.assertEqual(factory.session_class, CookieSession)
request = testing.DummyRequest(cookies={'SessionId': 'chocolate'})
session = factory(request)
client = session.client
self.assertIsInstance(client, MockCache)
self.assertEqual(client._serializer.dumps, serializer.json.dumps)
self.assertEqual(client.ttl, 20)
self.assertEqual(client.key_prefix, b'cookie::')
self.assertEqual(session['anotherkey'], 'another val')
self.assertEqual(request.response_callbacks,
deque([session.save_session]))
testing.tearDown()
开发者ID:Gandi,项目名称:pyramid_kvs,代码行数:25,代码来源:test_session.py
示例8: setUp
def setUp(self):
EPUBMixInTestCase.setUp(self)
testing.setUp(settings=self.settings)
init_db(self.db_conn_str)
# Assign API keys for testing
self.set_up_api_keys()
开发者ID:Connexions,项目名称:cnx-publishing,代码行数:7,代码来源:base.py
示例9: setUp
def setUp(self):
from pyramid import testing
from lasco.models import DBSession
from lasco.models import initialize_sql
testing.setUp()
initialize_sql(TESTING_DB)
self.session = DBSession
开发者ID:dbaty,项目名称:Lasco,代码行数:7,代码来源:test_models.py
示例10: setUp
def setUp(self):
testing.setUp()
self.engine = create_engine('sqlite:///:memory:')
self.session = sessionmaker(bind=self.engine)()
Base.metadata.create_all(self.engine)
self.request = testing.DummyRequest()
self.request.db = self.session
开发者ID:mathcamp,项目名称:mathclass,代码行数:7,代码来源:tests.py
示例11: test_user_view
def test_user_view(self):
"""
test the user_view view
if a user with user_id from URL exists,
"""
from c3sar.views.user import user_view
request = testing.DummyRequest()
request.matchdict['user_id'] = '1'
self.config = testing.setUp(request=request)
_registerRoutes(self.config)
instance = self._makeUser()
self.dbsession.add(instance)
# one more user
instance2 = self._makeUser2()
self.dbsession.add(instance2)
self.dbsession.flush()
result = user_view(request)
# test: view returns a dict containing a user
self.assertEquals(result['user'].username, instance.username)
request = testing.DummyRequest()
request.matchdict['user_id'] = '2'
self.config = testing.setUp(request=request)
result = user_view(request)
开发者ID:AnneGilles,项目名称:c3sar,代码行数:28,代码来源:test_user_views.py
示例12: test_backup
def test_backup(dbsession, ini_settings):
"""Execute backup script with having our settings content."""
f = NamedTemporaryFile(delete=False)
temp_fname = f.name
f.close()
ini_settings["websauna.backup_script"] = "websauna.tests:backup_script.bash"
ini_settings["backup_test.filename"] = temp_fname
# We have some scoping issues with the dbsession here, make sure we close transaction at the end of the test
with transaction.manager:
init = get_init(dict(__file__=ini_settings["_ini_file"]), ini_settings)
init.run()
testing.setUp(registry=init.config.registry)
# Check we have faux AWS variable to export
secrets = get_secrets(get_current_registry())
assert "aws.access_key_id" in secrets
try:
# This will run the bash script above
backup_site()
# The result should be generated here
assert os.path.exists(temp_fname)
contents = io.open(temp_fname).read()
# test-secrets.ini, AWS access key
assert contents.strip() == "foo"
finally:
testing.tearDown()
开发者ID:LukeSwart,项目名称:websauna,代码行数:35,代码来源:test_backup.py
示例13: test_should_renew_session_on_invalidate
def test_should_renew_session_on_invalidate(self):
settings = {'pyramid.includes': '\n pyramid_kvs.testing',
'kvs.session': """{"kvs": "mock",
"key_name": "SessionId",
"session_type": "cookie",
"codec": "json",
"key_prefix": "cookie::",
"ttl": 20}"""}
testing.setUp(settings=settings)
factory = SessionFactory(settings)
MockCache.cached_data = {
b'cookie::chocolate': '{"stuffing": "chocolate"}'
}
request = testing.DummyRequest(cookies={'SessionId': 'chocolate'})
session = factory(request)
# Ensure session is initialized
self.assertEqual(session['stuffing'], 'chocolate')
# Invalidate session
session.invalidate()
# session is invalidated
self.assertFalse('stuffing' in session)
# ensure it can be reused immediately
session['stuffing'] = 'macadamia'
self.assertEqual(session['stuffing'], 'macadamia')
testing.tearDown()
开发者ID:Gandi,项目名称:pyramid_kvs,代码行数:26,代码来源:test_session.py
示例14: setUp
def setUp(self):
"""Setup Tests"""
from pyramid.paster import get_app
app = get_app('test.ini', 'main')
from webtest import TestApp
self.testapp = TestApp(app)
testing.setUp()
开发者ID:briangershon,项目名称:Bookie,代码行数:7,代码来源:test_fulltext.py
示例15: setup_method
def setup_method(self, _):
testing.setUp(
settings={
"default_locale_name": "fr",
"default_max_age": 1000,
}
)
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:7,代码来源:test_entry.py
示例16: setUp
def setUp(self): # noqa
from pyramid import testing
testing.setUp(
settings={
"default_locale_name": "fr",
"default_max_age": 1000,
}
)
开发者ID:DavMerca007,项目名称:c2cgeoportal,代码行数:8,代码来源:test_entry.py
示例17: test_pyramid
def test_pyramid():
from tests.pyramid_app import revision, config
from pyramid import testing
testing.setUp(config.registry)
r = testing.DummyRequest()
result = revision(r)
assert result.status_code == 200
testing.tearDown()
开发者ID:klen,项目名称:dealer,代码行数:8,代码来源:test_dealer.py
示例18: setUp
def setUp(self):
# from katfud import main
# app = main({}, **{'katfud.conf_file': 'conf.yml', 'katfud.non_pi': True})
testing.setUp()
import katfud.runtime as runtime
self.test_runtime = runtime._Runtime(os.path.join(os.path.dirname(__file__), 'runtime_test.yml'))
开发者ID:ferdy-lw,项目名称:katfud-5000,代码行数:8,代码来源:runtime_test.py
示例19: setUp
def setUp(self):
"""Setup Transaction"""
testing.setUp()
self.testapp.post("/login",
{"username":"test",
"password":"test",
"submit":""})
self.session = meta.Session()
开发者ID:rwilkins87,项目名称:cogent-house,代码行数:8,代码来源:base.py
示例20: test_thumbor_filter_without_security_key
def test_thumbor_filter_without_security_key(self):
testing.setUp(settings={
'thumbor.security_key': None,
})
self.assertEqual(
thumbor_filter({}, 'image', 25, 25), '')
self.assertEqual(
thumbor_filter({}, 'image', 25), '')
开发者ID:universalcore,项目名称:springboard,代码行数:8,代码来源:test_filters.py
注:本文中的pyramid.testing.setUp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论