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


Python base.DBSession类代码示例

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


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

示例1: test_get

    def test_get(self):
        """
        Tests the ShareRepository.get method.
        """
        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share1').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share2').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share3').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share4').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)
开发者ID:C3S,项目名称:c3sMembership,代码行数:27,代码来源:test_share_repository.py

示例2: setUp

    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,代码行数:27,代码来源:test_membership_certificate.py

示例3: tearDown

 def tearDown(self):
     """
     Clean up database
     """
     DBSession().close()
     DBSession.remove()
     testing.tearDown()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:test_utils.py

示例4: delete_by_id

 def delete_by_id(cls, staff_id):
     """
     Delete one C3sStaff object by id.
     """
     row = DBSession.query(cls).filter(cls.id == staff_id).first()
     row.groups = []
     DBSession.query(cls).filter(cls.id == staff_id).delete()
开发者ID:C3S,项目名称:c3sMembership,代码行数:7,代码来源:staff.py

示例5: create

    def create(cls, membership_number, shares_quantity,
               board_confirmation=None):
        """
        Create a shares package.

        Args:
            membership_number: The membership number of the member for which
                the shares package is created.
            shares_quantity: The number of shares of the package to be created.
            board_confirmation: Optional. The date on which the board of
                directors confirmed the acquisition of the shares package.

        Returns:
            The technical primary key of the created shares package.
        """
        shares = Shares(
            number=shares_quantity,
            date_of_acquisition=board_confirmation,
        )
        # pylint: disable=no-member
        member = DBSession.query(C3sMember).filter(
            C3sMember.membership_number == membership_number).first()
        # pylint: disable=no-member
        DBSession.add(shares)
        member.shares.append(shares)
        member.num_shares += shares_quantity
        DBSession.flush()
        return shares.id
开发者ID:C3S,项目名称:c3sMembership,代码行数:28,代码来源:share_repository.py

示例6: test_create

    def test_create(self):
        """
        Tests the ShareRepository.create method.
        """
        # pylint: disable=no-member
        member1 = DBSession.query(C3sMember).filter(
            C3sMember.membership_number == 'member1').first()
        self.assertEqual(member1.num_shares, 12 + 23)

        share_id = ShareRepository.create('member1', 25, date(2016, 4, 23))
        self.assertEqual(member1.num_shares, 12 + 23 + 25)
        self.assertEqual(len(member1.shares), 3)

        # pylint: disable=no-member
        shares = DBSession.query(Shares).filter(Shares.id == share_id).first()
        self.assertEqual(shares.number, 25)
        self.assertEqual(shares.date_of_acquisition, date(2016, 4, 23))
        self.assertEqual(shares.reference_code, None)
        self.assertEqual(shares.signature_received, False)
        self.assertEqual(shares.signature_received_date, date(1970, 1, 1))
        self.assertEqual(shares.signature_confirmed, False)
        self.assertEqual(shares.signature_confirmed_date, date(1970, 1, 1))
        self.assertEqual(shares.payment_received, False)
        self.assertEqual(shares.payment_received_date, date(1970, 1, 1))
        self.assertEqual(shares.payment_confirmed, False)
        self.assertEqual(shares.payment_confirmed_date, date(1970, 1, 1))
        self.assertEqual(shares.accountant_comment, None)
开发者ID:C3S,项目名称:c3sMembership,代码行数:27,代码来源:test_share_repository.py

示例7: setUp

    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,代码行数:59,代码来源:test_webtest.py

示例8: __set_up_database

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

示例9: test_usage

 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,代码行数:9,代码来源:test_initialization.py

示例10: tearDown

 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,代码行数:9,代码来源:test_general_assembly_repository.py

示例11: init

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

示例12: delete

    def delete(cls, shares_id):
        """
        Deletes the shares package of the specified shares id.

        Args:
            shares_id: The technical primary key of the shares package to be
                deleted.
        """
        # pylint: disable=no-member
        DBSession.query(Shares).filter(Shares.id == shares_id).delete()
开发者ID:C3S,项目名称:c3sMembership,代码行数:10,代码来源:share_repository.py

示例13: tearDownClass

    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,代码行数:10,代码来源:integration_test_base.py

示例14: test_main_correct

 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,代码行数:12,代码来源:test_initialization.py

示例15: setUp

    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,代码行数:14,代码来源:test_join.py


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