-4

我想为登录页面编写一个测试。该方法是 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)

我要测试的是是否输入了用户名和密码,并且我想检查他/她是否提供密码。我想检查这个方法是否正确。告诉我我想在终端中进行测试的必要事项。

4

1 回答 1

1

你很幸运,因为 Plone 确实有一个你应该使用的测试框架。

https://ploneapptesting.readthedocs.org/en/latest/

于 2013-04-13T14:00:15.290 回答