예제 #1
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)
예제 #2
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)