""" This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". Replace this with more appropriate tests for your application. """ from .models import Pregunta, Respuesta from .views import califica_pregunta from django.test import TestCase from django.core.urlresolvers import reverse class RendereoCuestionario(TestCase): fixtures = ['cuestionario_dgtic.json', ] def test_requiere_datos_alumno_post(self): url = reverse('servicio:nuevoalumno') pregunta = Pregunta.objects.all()[0] datos = { 'nombre_alumno': 'Francisco', 'appat': 'Gomez', 'apma': 'Hernandez', 'area': 'Desarrollo', 'dependencia': '1', 'cuestionario': '2' } response = self.client.post(url, datos) self.assertContains(response, pregunta.nombre_pregunta) response = self.client.post(url) self.assertNotContains(response, pregunta.nombre_pregunta) def test_verificar_preguntas_orden_aleatorio(self): url = reverse('servicio:nuevoalumno') datos = { 'nombre_alumno': 'Francisco', 'appat': 'Gomez', 'apma': 'Hernandez', 'area': 'Desarrollo', 'dependencia': '1', 'cuestionario': '2' } response_1 = self.client.post(url, datos) response_2 = self.client.post(url, datos) self.assertHTMLNotEqual(response_1.content, response_2.content) class CalificaCuestionario(TestCase): fixtures = [ 'cuestionario_dgtic.json' ] def test_califica_pregunta_sencilla(self): pregunta = Pregunta.objects.get(pk=2) respuesta = Respuesta.objects.get(pk=3) self.assertTrue(califica_pregunta(pregunta, respuesta)) respuesta = Respuesta.objects.get(pk=2) self.assertFalse(califica_pregunta(pregunta, respuesta)) def test_califica_pregunta_multiple(self): self.fail("Terminar el test")