def initTestingDB(auditlog_types=False, auditlog_entries=False, groups=False, users=False, portlets=False, mailings=False): engine = create_engine('sqlite:///:memory:') Base.metadata.create_all(engine) Session.configure(bind=engine) if auditlog_types: add_audit_log_event_types() if groups or users: add_groups() if users: add_users() if mailings: add_mailings() add_demo_mailing() if portlets: add_demo_portlet() if auditlog_entries: add_demo_auditlog_entries()
def main(argv=sys.argv): if len(argv) < 2: usage(argv) config_uri = argv[1] options = parse_vars(argv[2:]) setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) engine = engine_from_config(settings, 'sqlalchemy.') Session.configure(bind=engine) Base.metadata.create_all(engine)
def bootstrap_pyramid(signal, sender): import os from pyramid.paster import bootstrap sender.app.settings = \ bootstrap(os.environ['BALISTOS_CONFIG'])['registry'].settings engine = engine_from_config(sender.app.settings, 'sqlalchemy.') register_after_fork(engine, engine.dispose) Session.configure(bind=engine)
def main(global_config, **settings): """This function returns a Pyramid WSGI application and is only used when developing BIMT in isolation.""" engine = engine_from_config(settings, 'sqlalchemy.') Session.configure(bind=engine) config = Configurator( settings=settings, root_factory=RootFactory, ) includeme(config) add_home_view(config) return config.make_wsgi_app()
def main(argv=sys.argv): # TODO: check for DB existance etc.? this fails if run more than once db_url = os.environ.get('DATABASE_URL') if not db_url and len(argv) > 1: env = bootstrap(argv[1]) db_url = env['app'].registry.settings['sqlalchemy.url'] if not db_url: print 'Set your database url in environment or provide .ini file' # noqa return settings = {'sqlalchemy.url': db_url} engine = engine_from_config(settings, 'sqlalchemy.') Session.configure(bind=engine) Base.metadata.create_all(engine) insert_data() print 'DB populated with dummy data: {0}'.format(db_url) # noqa
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" engine = engine_from_config(settings, 'sqlalchemy.') Session.configure(bind=engine) session_factory = UnencryptedCookieSessionFactoryConfig( settings.get('session.secret', 'secret'), ) authentication_policy = AuthTktAuthenticationPolicy( secret=settings.get('authtkt.secret', 'secret'), hashalg='sha512', callback=groupfinder, max_age=86400, ) authorization_policy = ACLAuthorizationPolicy() SOCIAL_AUTH_SETTINGS['SOCIAL_AUTH_FACEBOOK_KEY'] = settings['social.facebook_key'] # noqa SOCIAL_AUTH_SETTINGS['SOCIAL_AUTH_FACEBOOK_SECRET'] = settings['social.facebook_secret'] # noqa SOCIAL_AUTH_SETTINGS['SOCIAL_AUTH_GOOGLE_OAUTH2_KEY'] = settings['social.google_key'] # noqa SOCIAL_AUTH_SETTINGS['SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET'] = settings['social.google_secret'] # noqa settings.update(SOCIAL_AUTH_SETTINGS) config = Configurator( settings=settings, root_factory=RootFactory, authentication_policy=authentication_policy, authorization_policy=authorization_policy, session_factory=session_factory, ) is_sqlite = 'sqlite' in settings['sqlalchemy.url'] configure(config, sqlite=is_sqlite) DEVELOPER_KEY = settings['balistos.youtube_key'] # noqa config.include('pyramid_basemodel') config.include('pyramid_tm') config.include('social.apps.pyramid_app') init_social(config, Base, Session) config.scan('social.apps.pyramid_app') return config.make_wsgi_app()
def createTestDB(): engine = create_engine('sqlite:///:memory:') Session.configure(bind=engine) Base.metadata.create_all(engine) insert_data()
def test_filled(self): '''Test whether correct __LOCALE__ is left''' request = self._makeRequest() route_parameters = request.default_locale(slug='some-slug', __LOCALE__='pl') self.assertEqual(route_parameters['__LOCALE__'], 'pl') def test_filled_wrong(self): '''Test whether wrong locale is change''' request = self._makeRequest() route_parameters = request.default_locale(slug='some-slug', __LOCALE__='fr') self.assertTrue(route_parameters['__LOCALE__'] in request.config.localize.locales.available) engine = create_engine('sqlite://', echo=False) Session.configure(bind=engine) Base.metadata.bind = engine class RequestMethodTest(BaseRequestTest): def setUp(self): ''' setUp test method @see unittest.TestCase.setUp ''' Base.metadata.create_all(engine) for locale in ['pl', 'cz', 'fr']: locale_object = Language(name=text_type(locale), native_name=text_type(locale), language_code=text_type(locale))