我想为登录页面编写测试。方法是check_input,代码如下所示
def check_input(self):
form = self.request.form
username = form.get('name',"")
password = form.get('password',"")
session = getSession()
error = ''
print session
if (username == '' and password == ''):
error = "error: you must enter both username and password"
if (username!='') and(password == ''):
error = "you must enter password"
if (username and password) not in ['', None]:
result = session.execute("select UserName,Password from membership where UserName='%s' && Password='%s' "%(username,password))
if result:
records = result.fetchall()
if not records:
error = 'username and password do not match'
if not error:
return self.template_success(name=username)
else:
return self.template(error = error)
我想测试的是是否同时输入用户名和密码,还要检查他/她是否提供密码。我想检查一下这个方法是否正确。告诉我我想在终端进行测试的必要事项。