def test_user_reg_normal(self): # 环境检查 if db.chck_user(NOT_EXIST_USER): db.del_user(NOT_EXIST_USER) # 发送请求 data = {'name': NOT_EXIST_USER, 'password': '******'} res = requests.post(url=self.url, json=data) #期望响应结果,注意字典格式和json的区别(如果有true/false/null要转化成字典格式) except_res = { "code": "1000000", "msg": "成功", "data": { "name": NOT_EXIST_USER, "password": "******" } } #响应断言(整体断言) self.assertDictEqual(res.json(), except_res) #数据库断言 self.assertTrue(db.chck_user(NOT_EXIST_USER)) # 环境清理 db.del_user(NOT_EXIST_USER)
def deluser(): if not session.get('name'): return redirect('/login') #前端get请求,逻辑端通过request.args.get获取参数 uid = request.args.get("uid") print uid del_user(uid) return json.dumps({"code": 0, "result": "delete user success"})
def deluser(): if not session.get('name'): return redirect('/login') #前端get请求,逻辑端通过request.args.get获取参数 uid=request.args.get("uid") print uid del_user(uid) return redirect("/userlist")
def deluser(): if not session.get('name'): return redirect('/login') #前端get请求,逻辑端通过request.args.get获取参数 uid = request.args.get("uid") print uid del_user(uid) return redirect("/userlist")
def command_unsubscribe(message: telegram.Message, subcommand): chat_id = message.chat_id user = db.get_user(chat_id) if subcommand == []: if user != None: db.del_user(message.chat_id) message.reply_text("You're now unsubscribed!") else: message.reply_text("You're already unsubscribed")
def get(self): action = self.get_argument('action') if action == 'ck_mail': param = self.get_argument('param') res = db.signup_check('email', param) elif action == 'ck_pwd': param = self.get_argument('param') res = db.pwd_check(param) elif action == 'buy_att': buid = self.get_argument('buid') suid = self.get_argument('suid') cost = self.get_argument('cost') res = db.buy_att(buid, suid, cost) elif action == 'del_user': uid = self.get_argument('uid') res = db.del_user(uid) self.write(res)
def post(self): if 'action' not in request.args: return self.render() if request.args.get('action') == 'enable_user': res = enable_user(current_user.key, request.form.get('req_id')) elif request.args.get('action') == 'disable_user': res = disable_user(current_user.key, request.form.get('req_id')) elif request.args.get('action') == 'delete_user': res = del_user(current_user.key, request.form.get('req_id')) elif request.args.get('action') == 'modify_user': return self._modify_user(grant_only=False) elif request.args.get('action') == 'grant_access': return self._modify_user(grant_only=True) else: flash(f'Unknown action {request.args.get("action")}', category='danger') return self.render() if res is None or not res: flash('Error', category='danger') return self.render()
def new(user_id): db.del_user(user_id) message = 'Вы удалены!' vkapi.send_message(user_id, token, message, '')
def deluser(): #前端get请求,逻辑端通过request.args.get获取参数 uid = request.args.get("uid") print uid del_user(uid) return redirect("/userlist")
def deluser(): #前端get请求,逻辑端通过request.args.get获取参数 uid=request.args.get("uid") print uid del_user(uid) return redirect("/userlist")