def setup_database(global_config, **settings): """Setup database """ if 'engine' not in settings: settings['engine'] = (engine_from_config(settings, 'sqlalchemy.')) if 'session' not in settings: settings['session'] = scoped_session( sessionmaker( extension=ZopeTransactionExtension(keep_session=True), bind=settings['engine'], )) tables.set_now_func(datetime.datetime.utcnow) return settings
def setup_database(global_config, **settings): """Setup database """ if 'engine' not in settings: settings['engine'] = ( engine_from_config(settings, 'sqlalchemy.') ) if 'session' not in settings: settings['session'] = scoped_session(sessionmaker( extension=ZopeTransactionExtension(keep_session=True), bind=settings['engine'], )) tables.set_now_func(datetime.datetime.utcnow) return settings
def setUp(self): self.session = create_session() self._old_now_func = tables.set_now_func(utc_now) self.dummy_processor = DummyProcessor() self.model_factory = ModelFactory( session=self.session, processor_factory=lambda: self.dummy_processor, settings={}, ) self.company_model = self.model_factory.create_company_model() self.customer_model = self.model_factory.create_customer_model() self.plan_model = self.model_factory.create_plan_model() self.subscription_model = self.model_factory.create_subscription_model() self.invoice_model = self.model_factory.create_invoice_model() self.transaction_model = self.model_factory.create_transaction_model() self.transaction_failure_model = self.model_factory.create_transaction_failure_model()
def setUp(self): self.session = create_session() self._old_now_func = tables.set_now_func(utc_now) self.dummy_processor = DummyProcessor() self.model_factory = ModelFactory( session=self.session, processor_factory=lambda: self.dummy_processor, settings={}, ) self.company_model = self.model_factory.create_company_model() self.customer_model = self.model_factory.create_customer_model() self.plan_model = self.model_factory.create_plan_model() self.subscription_model = self.model_factory.create_subscription_model( ) self.invoice_model = self.model_factory.create_invoice_model() self.transaction_model = self.model_factory.create_transaction_model() self.transaction_failure_model = self.model_factory.create_transaction_failure_model( )
def tearDown(self): self.session.close() self.session.remove() tables.DeclarativeBase.metadata.drop_all() self.session.bind.dispose() tables.set_now_func(self._old_now_func)