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


Python DBSession.remove方法代码示例

本文整理汇总了Python中c3smembership.data.model.base.DBSession.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.remove方法的具体用法?Python DBSession.remove怎么用?Python DBSession.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c3smembership.data.model.base.DBSession的用法示例。


在下文中一共展示了DBSession.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
 def tearDown(self):
     """
     Clean up database
     """
     DBSession().close()
     DBSession.remove()
     testing.tearDown()
开发者ID:C3S,项目名称:c3sMembership,代码行数:9,代码来源:test_utils.py

示例2: setUp

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
    def setUp(self):
        self.config = testing.setUp()
        self.config.set_session_factory(session_factory_from_settings({}))
        self.config.include('pyramid_mailer.testing')
        self.config.include('pyramid_chameleon')
        self.config.include('c3smembership.presentation.view_processing')
        self.error_handler = TestErrorHandler()
        self.config.set_colander_error_handler(self.error_handler)
        DBSession.remove()
        self.db_session = init_testing_db()
        self.config.registry.settings['testing.mail_to_console'] = 'no'
        self.config.registry.settings['c3smembership.notification_sender'] = \
            '[email protected]'
        self.config.add_route('join', '/')
        self.config.add_route('detail', '/detail')
        self.config.add_route('dashboard', '/')
        self.config.add_route('certificate_pdf', '/')
        self.config.add_route(
            'certificate_pdf_staff', '/certificate_pdf_staff/{member_id}')
        self.config.add_route(
            'membership_listing_backend', '/membership_listing_backend')

        self.config.add_route(
            'certificate_mail', '/cert_mail/{member_id}')
        self.config.scan(
            'c3smembership.presentation.views.membership_certificate')
        self.testapp = TestApp(self.config.make_wsgi_app())
开发者ID:C3S,项目名称:c3sMembership,代码行数:29,代码来源:test_membership_certificate.py

示例3: setUp

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例4: test_usage

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例5: tearDown

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例6: tearDownClass

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
    def tearDownClass(cls):
        """
        Remove the database

        The database must be set up each time a test case is initialized in
        order to have clean data.
        """
        db_session = cls.get_db_session()
        db_session.close()
        DBSession.remove()
开发者ID:C3S,项目名称:c3sMembership,代码行数:12,代码来源:integration_test_base.py

示例7: test_main_correct

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例8: setUp

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
    def setUp(self):
        self.config = testing.setUp()
        self.config.include('pyramid_mailer.testing')
        self.config.registry.settings[
            'c3smembership.url'] = 'https://yes.c3s.cc'
        self.config.registry.settings['c3smembership.notification_sender'] = \
            '[email protected]'
        self.config.registry.settings['c3smembership.status_receiver'] = \
            '[email protected]'
        self.config.registry.settings['testing.mail_to_console'] = 'false'
        self.config.registry.get_mailer = get_mailer

        DBSession.remove()
        self.session = DBSession
开发者ID:C3S,项目名称:c3sMembership,代码行数:16,代码来源:test_join.py

示例9: test_main_false

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例10: setUp

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:41,代码来源:test_utils.py

示例11: setUp

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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

示例12: shutdown

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
 def shutdown(self):
     if isinstance(self.srv, StopableWSGIServer):
         self.srv.shutdown()
     DBSession.close()
     DBSession.remove()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:webdriver_utils.py

示例13: test_join_c3s

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [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()
开发者ID:C3S,项目名称:c3sMembership,代码行数:80,代码来源:test_join.py

示例14: test_init

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
 def test_init(self):
     from c3smembership.scripts.initialize_db import init
     init()
     DBSession.close()
     DBSession.remove()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:test_initialization.py

示例15: tearDown

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import remove [as 别名]
 def tearDown(self):
     DBSession.remove()
     # shutil.rm('c3sMembership.db')
     testing.tearDown()
开发者ID:C3S,项目名称:c3sMembership,代码行数:6,代码来源:test_gnupg.py


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