本文整理汇总了Python中c3smembership.data.model.base.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.data.model.base.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
my_settings = {"sqlalchemy.url": "sqlite:///:memory:", "api_auth_token": u"SECRETAUTHTOKEN"}
self.config = testing.setUp()
app = main({}, **my_settings)
# set up the database
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
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)
member1.email_invite_token_bcgv16 = u"MEMBERS_TOKEN"
DBSession.flush()
self.testapp = TestApp(app)
示例2: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [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)
示例3: __set_up_database
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def __set_up_database(cls):
"""
Set up the database and create staff
"""
engine = engine_from_config(cls.SETTINGS)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
cls.__create_staff()
示例4: init
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def init():
engine = engine_from_config({'sqlalchemy.url': 'sqlite://'})
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
# Setup alembic database migration information.
# This creates the alembic_version table in the database
# which is the basis for migrations and the "alembic current"
# command.
alembic_cfg = Config('alembic.ini')
command.stamp(alembic_cfg, 'head')
示例5: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
"""
Set up database and engine
"""
self.config = testing.setUp()
self.config.include('pyramid_mailer.testing')
DBSession().close()
DBSession.remove()
from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
DBSession.configure(bind=engine)
self.session = DBSession
Base.metadata.create_all(engine)
with transaction.manager:
# German member
member1 = C3sMember(
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'ABCDEFGBAR',
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',
)
db_session = DBSession()
db_session.add(member1)
db_session.flush()
示例6: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
my_settings = {
'sqlalchemy.url': 'sqlite:///:memory:',
'api_auth_token': u"SECRETAUTHTOKEN",
'c3smembership.url': u'localhost',
'c3smembership.notification_sender': u'[email protected]',
'c3smembership.status_receiver': u'te[email protected]',
'testing.mail_to_console': u'false',
}
self.config = testing.setUp()
app = main({}, **my_settings)
self.get_mailer = GetMailerDummy()
app.registry.get_mailer = self.get_mailer
app.registry.membership_application.datetime = DateTimeDummy(
datetime.datetime(2018, 4, 26, 12, 23, 34))
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
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()
self.testapp = TestApp(app)
示例7: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [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)
示例8: _initTestingDB
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def _initTestingDB():
"""
Set up a database for these tests: have some test data.
"""
my_settings = {'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
normal_de = C3sMember( # german normal
firstname=u'Ada Musiziert',
lastname=u'Traumhaft ÄÖÜ',
email=u'[email protected]',
address1=u"ada addr one",
address2=u"ada addr two",
postcode=u"12345",
city=u"Foostadt Ada",
country=u"Foocountry",
locale=u"de",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'NORMAL_DE1',
password=u'adasrandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=u'23',
)
normal_en = C3sMember( # english normal
firstname=u'James',
lastname=u'Musician',
email=u'[email protected]',
address1=u"james addr 1",
address2=u"james appartment 2",
postcode=u"12345",
city=u"Jamestown",
country=u"Jamescountry",
locale=u"en",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'NORMAL_DE',
password=u'jamesrandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"",
num_shares=u'2',
)
investing_de = C3sMember( # german investing
firstname=u'Herman',
lastname=u'Investorius',
email=u'[email protected]',
address1=u"addr one4",
address2=u"addr two4",
postcode=u"12344",
city=u"Footown M44",
country=u"Foocountr4",
locale=u"de",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'INVESTING_DE',
password=u'arandompasswor4',
date_of_submission=date.today(),
membership_type=u'investing',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=u'60',
)
investing_en = C3sMember( # english investing
firstname=u'Britany',
lastname=u'Investing',
email=u'[email protected]',
address1=u"aone5",
address2=u"atwo5",
postcode=u"12355",
city=u"Footown M45",
country=u"Foocountr5",
locale=u"en",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'INVESTING_EN',
password=u'arandompasswor5',
date_of_submission=date.today(),
membership_type=u'investing',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=u'60',
)
legal_entity_de = C3sMember( # german investing legal entity
firstname=u'Deutscher',
lastname=u'Musikverlag',
email=u'[email protected]',
address1=u"foo bulevard",
address2=u"123-345",
postcode=u"98765",
city=u"Foo",
country=u"Bar",
locale=u"de",
date_of_birth=date.today(),
#.........这里部分代码省略.........
示例9: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
my_settings = {'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
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=35,
)
member2 = C3sMember( # german
firstname=u'AAASomeFirstnäme',
lastname=u'XXXSomeLastnä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'ABCDEFGBAR',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=45,
)
member3 = C3sMember(
firstname=u'Not Approved',
lastname=u'Member',
email=u'[email protected]',
address1=u'Some Street 123',
address2=u'',
postcode=u"12345",
city=u"Some City",
country=u"Some Country",
locale=u"DE",
date_of_birth=date(1980, 1, 2),
email_is_confirmed=False,
email_confirm_code=u'NOT_APPROVED_MEMBER',
password=u'not_approved_member',
date_of_submission=date(1970, 1, 1),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u'',
num_shares=7,
)
# pylint: disable=no-member
DBSession.add(member1)
# pylint: disable=no-member
DBSession.add(member2)
# pylint: disable=no-member
DBSession.add(member3)
member1.membership_number = u'member1'
member1.membership_date = date(2013, 1, 1)
member1.membership_accepted = True
member2.membership_number = u'member2'
member2.membership_date = date(2013, 1, 1)
member2.membership_accepted = True
member3.payment_received_date = date(2016, 10, 11)
share = Shares()
share.reference_code = u'share1'
share.date_of_acquisition = date(2013, 1, 2)
share.payment_received_date = date(2012, 11, 10)
share.number = 12
member1.shares.append(share)
share = Shares()
share.reference_code = u'share2'
share.date_of_acquisition = date(2014, 2, 3)
share.payment_received_date = date(2012, 12, 31)
share.number = 23
member1.shares.append(share)
share = Shares()
share.reference_code = u'share3'
share.date_of_acquisition = date(2014, 3, 4)
share.payment_received_date = date(2014, 3, 3)
share.number = 34
#.........这里部分代码省略.........
示例10: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
"""
Set up tests
"""
datetime_mock = mock.Mock()
GeneralAssemblyRepository.datetime = datetime_mock
# pylint: disable=no-member
my_settings = {'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2014,
u'1. ordentliche Generalversammlung',
date(2014, 8, 23)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015,
u'2. ordentliche Generalversammlung',
date(2015, 6, 13)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015_2,
u'Außerordentliche Generalversammlung',
date(2015, 7, 16)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2016,
u'3. ordentliche Generalversammlung',
date(2016, 4, 17)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2017,
u'4. ordentliche Generalversammlung',
date(2017, 4, 2)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018,
u'5. ordentliche Generalversammlung',
date(2018, 6, 3)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018_2,
u'Außerordentliche Generalversammlung',
date(2018, 12, 1)))
member1 = C3sMember(
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=35,
)
member2 = C3sMember(
firstname=u'AAASomeFirstnäme',
lastname=u'XXXSomeLastnä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'ABCDEFGBAR',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=45,
)
member3 = C3sMember(
firstname=u'Not invited',
lastname=u'at all',
email=u'[email protected]',
address1=u'Some',
address2=u'Address',
postcode=u'45678',
city=u'Hamburg',
country=u'Germany',
locale=u'DE',
date_of_birth=date(1980, 1, 2),
email_is_confirmed=False,
email_confirm_code=u'member3',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
#.........这里部分代码省略.........
示例11: init_testing_db
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def init_testing_db():
"""
Initializes the memory database with test samples.
"""
my_settings = {
'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
# There is a side effect of test_initialization.py after which there
# are still records in the database although it is setup from scratch.
# Therefore, remove all members to have an empty table.
# pylint: disable=no-member
members = C3sMember.get_all()
for member in members:
DBSession.delete(member)
DBSession.flush()
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2014,
u'1. ordentliche Generalversammlung',
date(2014, 8, 23)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015,
u'2. ordentliche Generalversammlung',
date(2015, 6, 13)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015_2,
u'Außerordentliche Generalversammlung',
date(2015, 7, 16)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2016,
u'3. ordentliche Generalversammlung',
date(2016, 4, 17)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2017,
u'4. ordentliche Generalversammlung',
date(2017, 4, 2)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018,
u'5. ordentliche Generalversammlung',
date(2018, 6, 3)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018_2,
u'Außerordentliche Generalversammlung',
date(2018, 12, 1)))
# German person
member1 = C3sMember(
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'ABCDEFG1',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'23',
)
# English person
member2 = C3sMember(
firstname=u'AAASomeFirstnäme',
lastname=u'XXXSomeLastnä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"en",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFG2',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'23',
)
# German legal entity
member3 = C3sMember(
firstname=u'Cooles PlattenLabel',
lastname=u'SomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
#.........这里部分代码省略.........
示例12: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
"""
Set up the test data.
The test set is:
date amount firstname lastname reference membership_number
========== ====== ========= ======== ========= =================
2015-01-01 15.11 Jane Smith JANE 1
2015-01-03 15.13 Cassandra Jones CASSANDRA 3
2016-02-01 16.21 Jane Smith SMI 1
2016-02-02 16.22 John Smith JOHN 2
2016-02-03 16.23 Cassandra Jones JONES 3
2017-03-01 17.31 Jane Smith TH 1
2017-03-02 17.32 John Smith SMITH 2
2018-10-12 12.12 Cassandra Jones CJ18 3
2019-04-05 19.19 Jane Smith JS19 1
"""
my_settings = {'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
# pylint: disable=no-member
DBSession.add(self._create_member(
membership_number=1,
firstname=u'Jane',
lastname=u'Smith',
dues15_paid=True,
dues15_payment_date=date(2015, 1, 1),
dues15_payment_token=u'JANE',
dues15_payment_amount=Decimal('15.11'),
dues16_paid=True,
dues16_payment_date=date(2016, 2, 1),
dues16_payment_token=u'SMI',
dues16_payment_amount=Decimal('16.21'),
dues17_paid=True,
dues17_payment_date=date(2017, 3, 1),
dues17_payment_token=u'TH',
dues17_payment_amount=Decimal('17.31'),
dues19_paid=True,
dues19_payment_date=date(2019, 4, 5),
dues19_payment_token=u'JS19',
dues19_payment_amount=Decimal('19.19'),
))
DBSession.add(self._create_member(
membership_number=2,
firstname=u'John',
lastname=u'Smith',
dues15_paid=False,
dues15_payment_date=None,
dues15_payment_token=None,
dues15_payment_amount=None,
dues16_paid=True,
dues16_payment_date=date(2016, 2, 2),
dues16_payment_token=u'JOHN',
dues16_payment_amount=Decimal('16.22'),
dues17_paid=True,
dues17_payment_date=date(2017, 3, 2),
dues17_payment_token=u'SMITH',
dues17_payment_amount=Decimal('17.32'),
))
DBSession.add(self._create_member(
membership_number=3,
firstname=u'Cassandra',
lastname=u'Jones',
dues15_paid=True,
dues15_payment_date=date(2015, 1, 3),
dues15_payment_token=u'CASSANDRA',
dues15_payment_amount=Decimal('15.13'),
dues16_paid=True,
dues16_payment_date=date(2016, 2, 3),
dues16_payment_token=u'JONES',
dues16_payment_amount=Decimal('16.23'),
dues17_paid=False,
dues17_payment_date=None,
dues17_payment_token=None,
dues17_payment_amount=None,
dues18_paid=True,
dues18_payment_date=date(2018, 10, 12),
dues18_payment_token=u'CJ18',
dues18_payment_amount=Decimal('12.12'),
))
示例13: setUp
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def setUp(self):
self.config = testing.setUp()
self.config.include('pyramid_mailer.testing')
engine = create_engine(u'sqlite://')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
member1 = C3sMember(
firstname=u'firsie',
lastname=u'lastie',
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',
)
member2 = C3sMember( # german
firstname=u'AAASomeFirstnäme',
lastname=u'XXXSomeLastnä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'ABCDEFGBAR',
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',
)
member3 = C3sMember( # german
firstname=u'BBBSomeFirstnäme',
lastname=u'AAASomeLastnä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'ABCDEFGBAZ',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'investing',
member_of_colsoc=True,
name_of_colsoc=u"GEMA",
num_shares=23,
)
DBSession.add(member1)
DBSession.add(member2)
DBSession.add(member3)
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"[email protected]",
)
staffer1.groups = [accountants_group]
try:
DBSession.add(accountants_group)
DBSession.add(staffer1)
DBSession.flush()
except:
print("it borked! (rut)")
示例14: test_join_c3s
# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import configure [as 别名]
def test_join_c3s(self):
"""
Test the join form
"""
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)
with transaction.manager:
accountants_group = Group(name=u"staff")
db_session = DBSession()
db_session.add(accountants_group)
db_session.flush()
staffer1 = Staff(
login=u"rut",
password=u"berries",
email=u"[email protected]",
)
staffer1.groups = [accountants_group]
db_session.add(accountants_group)
db_session.add(staffer1)
db_session.flush()
app = main({}, **my_settings)
testapp = TestApp(app)
# sucess for valid entry
res = testapp.get('/', status=200)
form = self._fill_form_valid_natural(res.form)
res = form.submit(u'submit', status=302)
res = res.follow()
self.assertTrue('information below to be correct' in res.body)
# success for 18th birthday
res = testapp.get('/', status=200)
form = self._fill_form_valid_natural(res.form)
join.date = DummyDate(date(2018, 4, 29))
form['year'] = u'2000'
form['month'] = u'04'
form['day'] = u'29'
res = form.submit(u'submit', status=302)
res = res.follow()
self.assertTrue('information below to be correct' in res.body)
# failure on test one day before 18th birthday
res = testapp.get('/', status=200)
form = self._fill_form_valid_natural(res.form)
join.date = DummyDate(date(2018, 4, 29))
form['year'] = u'2000'
form['month'] = u'04'
form['day'] = u'30'
res = form.submit(u'submit', status=200)
self.assertTrue('underaged person is currently not' in res.body)
# failure for statute not checked
res = testapp.get('/', status=200)
form = self._fill_form_valid_natural(res.form)
form['got_dues_regulations'].value__set(False)
res = form.submit(u'submit', status=200)
# failure for dues regulations not checked
res = testapp.get('/', status=200)
form = self._fill_form_valid_natural(res.form)
form['got_dues_regulations'].value__set(False)
res = form.submit(u'submit', status=200)
# teardown
DBSession().close()
DBSession.remove()
testing.tearDown()