我阅读了制作单位测试的官方文件,但太过了。 我必须为<代码>生成一个单位测试案例。 AdminPaswordChangeForm, and two specified function in views.py
正在修改<代码>is_staff和is_active
的地位。
I have also wrote simple test cases to register an user. Follow is the method defined in views.py
(which are updating the password using AdminPasswordChangeForm
)
def user_change_password(request, id):
user = User.objects.get(pk=id)
form = AdminPasswordChangeForm(user, request.POST)
if form.is_valid():
new_user = form.save()
msg = _( Password changed successfully. )
request.user.message_set.create(message=msg)
return HttpResponseRedirect( ../../user/users )
else:
form = AdminPasswordChangeForm(user)
extra_context = {
form : form,
change : True
}
return direct_to_template(request,"users/user_password_change.html",
extra_context = extra_context)