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 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_account_permission(self): uid, gid = self._preuser() uname = "修改的名字" uemail = "youxiang" + str(int(time.time())) + "@gmail.com" usex = "女" uposition = "修改的职位" # "mobile": umobile, userinfo = { "name": uname, "email": uemail, "sex": usex, "position": uposition, "role": 2, "manage_group_id_list": [gid], "join_group_id_list": [gid] } Account().bdp.usermodify(uid, userinfo) # 新增api/sub/func_modify uinf2 = { "dsh_permission": 1, "dsh_manage": 1, "tb_permission": 1, "data_permission": 1, "machine_learning_permission": 1, "data_screen": 1, "date_filter_permission": 1, "function_manage": 1, "tb_manage": 1, "data_source_manage": 1, "tml_manage": 1, "account_permission": 1, "role": 2 } Account().bdp.funcmodify(uid, uinf2) uinfo = Account.subinfo(uid) assert uinfo['userid'] == uid assert uinfo['account_permission'] == 1 assert uinfo['dsh_permission'] == 1 assert uinfo['dsh_manage'] == 1 assert uinfo['tb_permission'] == 1 assert uinfo['data_permission'] == 1 assert uinfo['data_screen'] == 1 assert uinfo['date_filter_permission'] == 1 assert uinfo['function_manage'] == 1 assert uinfo['tb_manage'] == 1 assert uinfo['data_source_manage'] == 1 assert uinfo['tml_manage'] == 1 assert uinfo['role'] == 2 assert uinfo['manage_groups'][0]['group_id'] == gid assert uinfo['name'] == uname assert uinfo['sex'] == usex assert uinfo['position'] == uposition assert uinfo['email'] == uemail assert len(uinfo['groups']) == 2 # 清除数据 Account.user_del(uid)
def test_userreset_pwd(self): uid, gid = self._preuser() # 处于重置密码状态 Account.reset_pwd(uid) uinfo = Account.subinfo(uid) assert uinfo['status'] == 2 # 重新设定密码 repassword = "******" Account.init_pwd(uid, repassword) uinfo = Account.subinfo(uid) assert uinfo['status'] == 0 # 清除数据 Account.user_del(uid)
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)