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


Python Session.rollback方法代码示例

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


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

示例1: test_05_orphans

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
 def test_05_orphans(self):
     """ Test that orphans are forbidden for the `Photo` model."""
     test_photo = OrphanPhotoData.JohnSmithPhoto()
     photo = model.Photo(path=test_photo.path)
     Session.add(photo)
     try:
         Session.commit()
         raise AssertionError('`Photo` delete-orphans constraint is missing.')
     except sa.exc.FlushError:
         Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:12,代码来源:test_photo.py

示例2: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Photo` model.

        Test the unique constraint on `path`.
        """
        test_photo = DuplicatePhotoData.JohnDoePhoto()
        person = Session.query(model.Person).filter_by().first()
        person.photo = model.Photo(path=test_photo.path)
        try:
            Session.commit()
            raise AssertionError('`Photo` unique constraint on `path` is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:15,代码来源:test_photo.py

示例3: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Permission` model.

        Test the unique constraint on `group_name`.
        """
        test_permission = DuplicatePermissionData.View()
        permission = model.Permission(
            permission_name=test_permission.permission_name,
            description=test_permission.description
        )
        Session.add(permission)
        try:
            Session.commit()
            raise AssertionError('`Permission` unique constraint on `group_name`, is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:18,代码来源:test_permissions.py

示例4: test_04_orphans

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
 def test_04_orphans(self):
     """ Test that orphans are forbidden for the `Excavation` model."""
     test_excavation = OrphanExcavationData.ExcavationSite2()
     excavation = model.Excavation(
         site_name=test_excavation.site_name,
         start_date=test_excavation.start_date,
         end_date=test_excavation.end_date,
         appreciation=test_excavation.appreciation
     )
     Session.add(excavation)
     try:
         Session.commit()
         raise AssertionError("`Excavation` delete-orphans constraint \
             is missing.")
     except sa.exc.FlushError:
         Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:18,代码来源:test_excavation.py

示例5: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Group` model.

        Test the unique constraint on `group_name`.
        """
        test_group = DuplicateGroupData.Guests()
        group = model.Group(
            group_name=test_group.group_name,
            display_name=test_group.display_name
        )
        Session.add(group)
        try:
            Session.commit()
            raise AssertionError('`Group` unique constraint on `group_name`, \
                is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:19,代码来源:test_group.py

示例6: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `User` model.

        Test the unique constraint on `user_name`.
        """
        test_user = DuplicateUserData.Guest()
        user = model.User(
            user_name=test_user.user_name,
            email_address=test_user.email_address,
            password=test_user.password,
            display_name=test_user.display_name
        )
        Session.add(user)
        try:
            Session.commit()
            raise AssertionError('`User` unique constraint on `user_name`, is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:20,代码来源:test_user.py

示例7: test_05_orphans

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
 def test_05_orphans(self):
     """ Test that orphans are forbidden for the `Address` model."""
     test_address = OrphanAddressData.JohnSmithAddress()
     address = model.Address(
         address_line1 = test_address.address_line1,
         address_line2 = test_address.address_line2,
         address_line3 = test_address.address_line3,
         zip_code = test_address.zip_code,
         city = test_address.city,
         country = test_address.country,
         address_type = test_address.address_type
     )
     Session.add(address)
     try:
         Session.commit()
         raise AssertionError('`Address` delete-orphans constraint is missing.')
     except sa.exc.FlushError:
         Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:20,代码来源:test_address.py

示例8: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Person` model.

        Test the unique constraint on `last_name` and `first_name`.
        """
        test_person = DuplicatePersonData.JohnDoe()
        person = model.Person(
            last_name=test_person.last_name,
            first_name=test_person.first_name,
            title=test_person.title,
            birth_date=test_person.birth_date,
            activity=test_person.activity
        )
        Session.add(person)
        try:
            Session.commit()
            raise AssertionError('`Person` unique constraint on `last_name` \
                                 and `first_name` is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:22,代码来源:test_person.py

示例9: test_03_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_03_unique_constraint(self):
        """ Test for unique constraint for the `VoluntaryMember` model.

        Test the unique constraint on `member_number`.
        """
        test_v_member = DuplicateVoluntaryMemberData.MaryJohnes()
        v_member = model.VoluntaryMember(
            last_name=test_v_member.last_name,
            first_name=test_v_member.first_name,
            title=test_v_member.title,
            birth_date=test_v_member.birth_date,
            activity=test_v_member.activity,
            member_number=test_v_member.member_number,
            last_fee_date=test_v_member.last_fee_date
        )
        Session.add(v_member)
        try:
            Session.commit()
            raise AssertionError('`VoluntaryMember` unique constraint on `member_number` is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:23,代码来源:test_voluntary_member.py

示例10: test_02_unique_constraint

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import rollback [as 别名]
    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Address` model.

        Test the unique constraint on `person_id` and `address_type`."""
        test_address = DuplicateAddressData.JohnDoeAddress()
        person = Session.query(model.Person).filter_by().first()
        person.addresses.append(
            model.Address(
                address_line1 = test_address.address_line1,
                address_line2 = test_address.address_line2,
                address_line3 = test_address.address_line3,
                zip_code = test_address.zip_code,
                city = test_address.city,
                country = test_address.country,
                address_type = test_address.address_type
            )
        )
        try:
            Session.commit()
            raise AssertionError('`Address` unique constraint on `person_id` and `address_type` is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:24,代码来源:test_address.py


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