本文整理汇总了Python中c3smembership.data.model.base.DBSession.close方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.close方法的具体用法?Python DBSession.close怎么用?Python DBSession.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.data.model.base.DBSession
的用法示例。
在下文中一共展示了DBSession.close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def setUp(self):
self.config = testing.setUp()
self.config.include('pyramid_mailer.testing')
try:
DBSession.close()
DBSession.remove()
# print("removed old DBSession ==============================")
except:
# print("no DBSession to remove =============================")
pass
# try:
# os.remove('test_webtest_functional.db')
# #print "deleted old test database"
# except:
# pass
# #print "never mind"
my_settings = {
# 'sqlalchemy.url': 'sqlite:///test_webtest_functional.db',
'sqlalchemy.url': 'sqlite:///:memory:',
'available_languages': 'da de en es fr',
'c3smembership.notification_sender': '[email protected]',
'testing.mail_to_console': 'false'}
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
self.session = DBSession # ()
Base.metadata.create_all(engine)
# dummy database entries for testing
with transaction.manager:
member1 = C3sMember( # german
firstname=u'SomeFirstnäme',
lastname=u'SomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
postcode=u"12345",
city=u"Footown Mäh",
country=u"Foocountry",
locale=u"DE",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFGFOO',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=u'23',
)
DBSession.add(member1)
DBSession.flush()
from c3smembership import main
app = main({}, **my_settings)
app.registry.get_mailer = get_mailer
from webtest import TestApp
self.testapp = TestApp(app)
示例2: test_usage
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def test_usage(self):
from c3smembership.scripts.initialize_db import usage
argv = ['initialize_c3sMembership_db']
try:
usage(argv)
except:
pass
DBSession.close()
DBSession.remove()
示例3: tearDown
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def tearDown(self):
"""
Tear down the set setup
"""
# pylint: disable=no-member
DBSession.close()
# pylint: disable=no-member
DBSession.remove()
GeneralAssemblyRepository.datetime = datetime
示例4: test_main_correct
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def test_main_correct(self):
"""
test the initialize_c3sMembership_db script with correct arguments
"""
from c3smembership.scripts.initialize_db import main
filename = 'webdrivertest.db'
if os.path.isfile(filename):
os.unlink(filename)
argv = ['initialize_c3sMembership_db', 'webdrivertest.ini']
main(argv)
DBSession.close()
DBSession.remove()
示例5: test_main_false
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def test_main_false(self):
"""
test the initialize_c3sMembership_db script with faulty arguments
get it wrong: wrong arguments:
* must be at least one argument
* must be name of an existing file
this gets coverage for the "usage" function in scripts/initialize_db.py
"""
from c3smembership.scripts.initialize_db import main
argv = []
with self.assertRaises(IndexError):
main(argv)
argv = ['notExisting.ini', ]
with self.assertRaises(SystemExit) as context:
main(argv)
self.assertEqual(context.exception.code, 1)
DBSession.close()
DBSession.remove()
示例6: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def setUp(self):
"""
Setup test cases
"""
self.config = testing.setUp()
self.config.include('pyramid_mailer.testing')
DBSession.close()
DBSession.remove()
my_settings = {
'sqlalchemy.url': 'sqlite:///:memory:',
'available_languages': 'da de en es fr',
'c3smembership.dashboard_number': '30'}
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
# self._insert_members()
with transaction.manager:
# a group for accountants/staff
accountants_group = Group(name=u"staff")
DBSession.add(accountants_group)
DBSession.flush()
# staff personnel
staffer1 = Staff(
login=u"rut",
password=u"berries",
email=u"[email protected]",
)
staffer1.groups = [accountants_group]
DBSession.add(accountants_group)
DBSession.add(staffer1)
DBSession.flush()
app = main({}, **my_settings)
self.testapp = TestApp(app)
示例7: tearDown
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def tearDown(self):
DBSession.close()
DBSession.remove()
testing.tearDown()
示例8: shutdown
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def shutdown(self):
if isinstance(self.srv, StopableWSGIServer):
self.srv.shutdown()
DBSession.close()
DBSession.remove()
示例9: test_init
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def test_init(self):
from c3smembership.scripts.initialize_db import init
init()
DBSession.close()
DBSession.remove()
示例10: tearDown
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import close [as 别名]
def tearDown(self):
# pylint: disable=no-member
DBSession.close()
# pylint: disable=no-member
DBSession.remove()