Exemplo n.º 1
0
 def test_create_user(self):
     username = "******" + str(time.time())
     password = "******"
     # 用户所属分组
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(username, pid)
     ginfo = group.groupinfo(gid)
     assert ginfo["group_name"] == username
     assert ginfo["group_id"] == gid
     assert ginfo["parent_group_id"] == pid
     # 测试创建普通用户
     uid = Account.create(username, password, gid)
     uinfo = Account.subinfo(uid)
     assert uinfo['userid'] == uid
     assert uinfo['username'] == username
     assert uinfo['account_permission'] == 0
     assert uinfo['role'] == 3
     assert uinfo['manage_groups'] == []
     # 测试冻结
     sta = Account.userfrozen(uid, 1)
     with pytest.raises(AssertionError):
         Account.user_login(username, password)
     assert json.loads(BdpSDK.instance().raw_data)["status"] == "1029"
     # 测试解冻
     Account.userfrozen(uid, 0)
     # res = Account.user_login(username, pw)
     # assert res["result"] is not None
     # 清除测试数据
     Account.user_del(uid)
Exemplo n.º 2
0
 def test_create_adminuser(self):
     username = "******" + str(time.time())
     password = "******"
     # 管理员管理分组
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(username, pid)
     ginfo = group.groupinfo(gid)
     assert ginfo["group_name"] == username
     assert ginfo["group_id"] == gid
     assert ginfo["parent_group_id"] == pid
     # 测试创建管理员
     uid = Account.create(username, password, gid, admin=True)
     uinfo = Account.subinfo(uid)
     assert uinfo['userid'] == uid
     assert uinfo['username'] == username
     assert uinfo['account_permission'] == 0
     assert uinfo['role'] == 2
     assert uinfo['manage_groups'][0]['group_id'] == gid
     # 测试冻结
     sta = Account.userfrozen(uid, 1)
     assert sta['status'] == "0"
     with pytest.raises(AssertionError):
         Account.user_login(username, password)
     assert json.loads(BdpSDK.instance().raw_data)["status"] == "1029"
     # 测试解冻
     Account.userfrozen(uid, 0)
     # 清除数据
     Account.user_del(uid)
Exemplo n.º 3
0
 def test_create_group(self):
     name = "groupname" + str(time.time())
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(name, pid)
     ginfo = group.groupinfo(gid)
     assert ginfo["group_name"] == name
     assert ginfo["group_id"] == gid
     assert ginfo["parent_group_id"] == pid
Exemplo n.º 4
0
 def test_groupname_repeat(self):
     name = "groupname" + str(time.time())
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(name, pid)
     result = group.groupinfo(gid)
     assert result["group_name"] == name
     assert result["parent_group_id"] == pid
     with pytest.raises(AssertionError):
         group.create(name, pid)
     assert json.loads(group().bdp.raw_data)["status"] == "12002"
     # 不同层级允许名称相同
     ggid = group.create(name, gid)
     result = group.groupinfo(ggid)
     assert result["group_name"] == name
     assert result["parent_group_id"] == gid
Exemplo n.º 5
0
 def _preuser(self):
     username = "******" + str(time.time())
     password = "******"
     # 用户所属分组
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(username, pid)
     ginfo = group.groupinfo(gid)
     assert ginfo["group_name"] == username
     assert ginfo["group_id"] == gid
     assert ginfo["parent_group_id"] == pid
     # 测试创建普通用户
     uid = Account.create(username, password, gid)
     uinfo = Account.subinfo(uid)
     assert uinfo['userid'] == uid
     assert uinfo['username'] == username
     assert uinfo['account_permission'] == 0
     assert uinfo['role'] == 3
     assert uinfo['manage_groups'] == []
     return uid, gid
Exemplo n.º 6
0
 def test_group_user_manager(self):
     name = "test_group_user_manager" + str(time.time())
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(name, pid)
     result = group.groupinfo(gid)
     assert result["group_name"] == name
     assert result["group_id"] == gid
     assert result["parent_group_id"] == pid
     # 准备组员、管理员
     username = "******" + str(time.time())
     password = "******"
     uid = Account.create(username, password, gid)
     uinfo = Account.subinfo(uid)
     assert uinfo['userid'] == uid
     assert uinfo['username'] == username
     assert uinfo['account_permission'] == 0
     assert uinfo['role'] == 3
     assert uinfo['manage_groups'] == []
     #is_extrace 已经废弃
     #assert uinfo['is_extrace'] == 0
     user_ids = [uid]
     # 添加组员/管理员
     group().bdp.groupmodify(gid, user_list=user_ids,manage_group_id_list=user_ids)
     result = group.groupinfo(gid)
     assert result["group_name"] == name
     assert result["group_id"] == gid
     assert result["parent_group_id"] == pid
     # assert result["manager_user_list"][0]["user_id"] == uid
     assert sorted(result["manager_user_list"])[0]["user_id"]== uid
     assert result["user_list"][0]["userid"] == uid
     # 删除组员/管理员
     uids = []
     group().bdp.groupmodify(gid, user_list=uids,manage_group_id_list=uids)
     result = group.groupinfo(gid)
     assert result["group_name"] == name
     assert result["group_id"] == gid
     assert result["parent_group_id"] == pid
     assert result["user_list"] == uids
     #清理
     Account.user_del(uid)
Exemplo n.º 7
0
 def test_groupmodify(self):
     name = "m1groupname" + str(time.time())
     pid = group.grouplist()[0]["group_id"]
     count = 0
     while (count < 2):
         gid = group.create(name, pid)
         if count == 0:
             T = gid
         result = group.groupinfo(gid)
         assert result["group_name"] == name
         assert result["group_id"] == gid
         assert result["parent_group_id"] == pid
         count = count + 1
         name = "m2groupname" + str(time.time())
     # 修改分组2
     name1 = "bdpmodifygroupname" + str(time.time())
     # call_method_and_succ not support **kwargs
     # group.groupmodify(gid, name=name1, parent_group_id=T)
     group().bdp.groupmodify(gid, name=name1, parent_group_id=T)
     result = group.groupinfo(gid)
     assert result["group_name"] == name1
     assert result["group_id"] == gid
     assert result["parent_group_id"] == T
Exemplo n.º 8
0
 def test_create_10group(self):
     name = "10grouptest" + str(time.time())
     pid = group.grouplist()[0]["group_id"]
     gid = group.create(name, pid)
     T = gid
     result = group.groupinfo(gid)
     assert result["group_name"] == name
     assert result["group_id"] == gid
     assert result["parent_group_id"] == pid
     count = 1
     while (count < 11):
         name = "10grouptest" + str(count) + str(time.time())
         if count == 10:
             with pytest.raises(AssertionError):
                 group.create(name, gid)
             assert json.loads(group().bdp.raw_data)["status"] == "12012"
         else:
             ggid = group.create(name, gid)
             result = group.groupinfo(ggid)
             assert result["group_name"] == name
             assert result["group_id"] == ggid
             assert result["parent_group_id"] == gid
             gid = ggid
         count = count + 1