Estoy tratando de averiguar si hay una forma rápida de probar mis funciones de vista django desde el shell python o django. ¿Cómo podría crear instancias y pasar un objeto HTTPrequest falso?Django view testing
5
A
Respuesta
0
Suena como desea el cliente de prueba Django https://docs.djangoproject.com/en/dev/topics/testing/#module-django.test.client
2
Si está utilizando Django 1.3, echar un vistazo a la RequestFactory incluido.
5
El django.test.client
sería el camino a seguir.
Desde el django docs
from django.test.client import Client
c = Client()
response = c.post('/login/', {'username': 'john', 'password': 'smith'})
response.status_code
1
Debe retirar django.test.client.Client o django.test.client.RequestFactory las cuales están documentadas en las instalaciones de la unidad de pruebas de Django: https://docs.djangoproject.com/en/1.3/topics/testing/
también sugieren utilizando respuestas de plantilla en sus vistas, ya que le permiten inspeccionar el contexto utilizado para representar la plantilla: http://docs.djangoproject.com/en/1.3/ref/template-response/
Cuestiones relacionadas
- 1. Asp.net MVC View Testing?
- 2. django ajax proxy view
- 3. Django Class Based View Composite
- 4. Django view security and best-practices
- 5. Django "view no devolvió un objeto HttpResponse".
- 6. UI testing vs unit testing
- 7. Testing helpers
- 8. C++ Unit Testing Libraries
- 9. Integration vs Unit Testing
- 10. Java Card Unit Testing
- 11. RSpec send_file testing
- 12. Java Security Testing
- 13. Black Box Unit Testing
- 14. UI Testing Tool?
- 15. PyQT GUI Testing
- 16. Silverlight Unit Testing
- 17. Grails Spring Security Testing
- 18. Integration Testing the Canvas
- 19. Grails withCriteria testing
- 20. ASP.NET Session Timeout Testing
- 21. Testing Spring @MVC anotaciones
- 22. Load Testing Software
- 23. unit testing modular javascript
- 24. Hit-testing formas SVG?
- 25. Monkey testing for iPhone?
- 26. .NET Unit Testing packages?
- 27. ResourceManager and Unit Testing
- 28. Haskell IO Testing
- 29. Javascript Sandbox unit testing
- 30. Unit Testing EJB 3.1