def test_doubleusername(self): uid, gid = self._preuser() uinfo = Account.subinfo(uid) username = uinfo['username'] with pytest.raises(AssertionError): Account.create(username, "123qweasd", gid) assert json.loads(BdpSDK.instance().raw_data)["status"] == "8003" Account.user_del(uid)
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)
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)
def aatest_xianjincreate_user(self): count = 0 mobile = 1800000000 while (count < 1): username = "******" + str(count) uid = Account.create(username, "123qweasd", mobile) count = count + 1 mobile = mobile + 1
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
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)