我完全陌生,在Django的测试。我已经开始安装鼻子和硒现在我想测试下面的代码(如下)它发送一条短信。Django鼻子如何写这个测试?
这是实际的代码:
views.py
@login_required
def process_all(request):
"""
I process the sending for a single or bulk message(s) to a group or single contact.
:param request:
"""
#If we had a POST then get the request post values.
if request.method == 'POST':
batches = Batch.objects.for_user_pending(request.user)
for batch in batches:
ProcessRequests.delay(batch)
batch.complete_update()
return HttpResponseRedirect('/reports/messages/')
所以我从哪里开始?这是我迄今为止所做的...
1)创建了一个名为测试的文件夹并添加了init .py。
2)创建了一个名为test_views.py的新的python文件(我假设这是正确的)。
现在,我该怎么写这个测试?
有人能告诉我一个如何为上面的视图编写测试的例子吗?
谢谢:)
https://docs.djangoproject.com/en/1.5/topics/testing/&https://docs.djangoproject.com/en/1.5/topics/testing/overview/ –