예제 #1
0
파일: Group.py 프로젝트: luzi82/HiSocial
 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"))
예제 #2
0
파일: Group.py 프로젝트: luzi82/HiSocial
    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"))
예제 #3
0
    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
예제 #4
0
    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)