def setUp(self): self.config = testing.setUp() self.config.include('pyramid_mailer.testing') try: DBSession.remove() #print("removing old DBSession =======================") except: #print("no DBSession to remove =======================") pass #engine = create_engine('sqlite:///test_models.db') engine = create_engine('sqlite:///:memory:') self.session = DBSession DBSession.configure(bind=engine) # XXX does influence self.session!?! Base.metadata.create_all(engine)
def tearDown(self): DBSession.remove() testing.tearDown()
def setUp(self): self.config = testing.setUp() self.config.include('pyramid_mailer.testing') try: DBSession.close() DBSession.remove() #print "closed and removed DBSession" except: pass #print "no session to close" my_settings = { 'sqlalchemy.url': 'sqlite:///:memory:', 'available_languages': 'da de en es fr', 'zabo.dashboard_number': '32', 'foo': 'bar', 'mailrecipient': '*****@*****.**', 'mail.debug': True, 'mail_from': '*****@*****.**', 'pyramid.includes': 'pyramid_mailer.testing', 'the_url': 'http://example.com', 'financial_blog_url_de': 'https://www.c3s.cc/ueber-c3s/finanzierung/', 'financial_blog_url_en': 'https://www.c3s.cc/en/about-us//financing/', 'base_path': '.' } engine = engine_from_config(my_settings) DBSession.configure(bind=engine) Base.metadata.create_all(engine) self._insert_abos() with transaction.manager: # a group for accountants/staff accountants_group = Group(name=u"staff") try: DBSession.add(accountants_group) DBSession.flush() #print("adding group staff") except: print("could not add group staff.") # pass # staff personnel staffer1 = Staff( login=u"rut", password=u"berries", email=u"*****@*****.**", ) staffer1.groups = [accountants_group] try: DBSession.add(accountants_group) DBSession.add(staffer1) DBSession.flush() except: print("could not add staffer1") # pass from zabo import main import pyramid registry = pyramid.registry.Registry() app = main({}, registry=registry, **my_settings) from webtest import TestApp self.testapp = TestApp(app)