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


Python Database.create_sqlalchemy_session方法代码示例

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


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

示例1: test_get_name

# 需要导入模块: from base import Database [as 别名]
# 或者: from base.Database import create_sqlalchemy_session [as 别名]
 def test_get_name(self):
     cleanup = Cleanup()
     session = Database.create_sqlalchemy_session()
     cleanup.push(session.close)
     
     self.assertEqual(None, Group.get_name(session,"asdf"))
     Group.add(session,"asdf","qwer")
     self.assertEqual("qwer", Group.get_name(session,"asdf"))
开发者ID:luzi82,项目名称:HiSocial,代码行数:10,代码来源:Group.py

示例2: test_rename

# 需要导入模块: from base import Database [as 别名]
# 或者: from base.Database import create_sqlalchemy_session [as 别名]
    def test_rename(self):
        cleanup = Cleanup()
        session = Database.create_sqlalchemy_session()
        cleanup.push(session.close)
        
        Group.add(session,"asdf","qwer")
        self.assertEqual("qwer", Group.get_name(session,"asdf"))
        self.assertNotEqual("zxcv", Group.get_name(session,"asdf"))
        self.assertTrue(Group.rename(session,"asdf","zxcv"))
        self.assertEqual("zxcv", Group.get_name(session,"asdf"))
        self.assertNotEqual("qwer", Group.get_name(session,"asdf"))

        self.assertFalse(Group.rename(session,"xxx","xxx"))
开发者ID:luzi82,项目名称:HiSocial,代码行数:15,代码来源:Group.py

示例3: test_unset

# 需要导入模块: from base import Database [as 别名]
# 或者: from base.Database import create_sqlalchemy_session [as 别名]
    def test_unset(self):
        cleanup = Cleanup()
        session = Database.create_sqlalchemy_session()
        cleanup.push(session.close)

        self.assertEqual(GroupPermission.get(session,"g0","p0"),None)
        Group.add(session,"g0","G-0")
        session.flush()
        self.assertEqual("G-0", Group.get_name(session,"g0"))
        self.assertEqual(GroupPermission.get(session,"g0","p0"),None)
        GroupPermission.set(session,"g0","p0",10,True)
        session.flush()
        self.assertEqual(GroupPermission.get(session,"g0","p0"),{GroupPermission.KEY_ORDER:10,GroupPermission.KEY_ENABLE:True})
        GroupPermission.unset(session,"g0","p0")
        session.flush()
        self.assertEqual(GroupPermission.get(session,"g0","p0"),None)

        pass
开发者ID:luzi82,项目名称:HiSocial,代码行数:20,代码来源:GroupPermission.py

示例4: test_get_user_permission

# 需要导入模块: from base import Database [as 别名]
# 或者: from base.Database import create_sqlalchemy_session [as 别名]
    def test_get_user_permission(self):
        cleanup = Cleanup()
        session = Database.create_sqlalchemy_session()
        cleanup.push(session.close)
        
        User.add_user_account(session, "u0", "up0")
        Group.add(session, "g0", "g0")
        UserGroup.join(session, "u0", "g0")
        self.assertEqual(Permission.get_user_permission(session, "u0", "p0"), False)
        GroupPermission.set(session, "g0", "p0", 10, True)
        self.assertEqual(Permission.get_user_permission(session, "u0", "p0"), True)
        GroupPermission.set(session, "g0", "p0", 20, False)
        self.assertEqual(Permission.get_user_permission(session, "u0", "p0"), False)
        Group.add(session, "g1", "g1")
        UserGroup.join(session, "u0", "g1")
        GroupPermission.set(session, "g1", "p0", 30, True)
        self.assertEqual(Permission.get_user_permission(session, "u0", "p0"), True)

        self.assertEqual(Permission.get_user_permission(session, "u1", "p0"), False)
        self.assertEqual(Permission.get_user_permission(session, "u0", "p1"), False)
开发者ID:luzi82,项目名称:HiSocial,代码行数:22,代码来源:Permission.py


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