当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.close方法代码示例

本文整理汇总了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)
开发者ID:C3S,项目名称:c3sMembership,代码行数:61,代码来源:test_webtest.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:11,代码来源:test_initialization.py

示例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
开发者ID:C3S,项目名称:c3sMembership,代码行数:11,代码来源:test_general_assembly_repository.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:14,代码来源:test_initialization.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:22,代码来源:test_initialization.py

示例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)
开发者ID:C3S,项目名称:c3sMembership,代码行数:38,代码来源:test_membership_member_edit.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:6,代码来源:test_shares_webtest.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:webdriver_utils.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:test_initialization.py

示例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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:test_share_repository.py


注:本文中的c3smembership.data.model.base.DBSession.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。