【发布时间】:2013-06-18 10:30:18
【问题描述】:
我对 Django 中的 测试 完全陌生。我已经开始安装 nose 和 selenium,现在我想测试以下代码 (如下) 它会发送一条 SMS 消息。
这是实际代码:
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) 创建了一个名为 tests 的文件夹并添加了 init.py。
2) 创建了一个名为 test_views.py 的新 python 文件(我假设这是正确的)。
现在,我该如何编写这个测试?
谁能告诉我如何为上面的视图编写测试的示例?
谢谢你:)
【问题讨论】:
标签: python django unit-testing testing nose