1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 02:06:52 +00:00

Test registration search

This commit is contained in:
Yohann D'ANELLO 2020-11-02 12:34:27 +01:00
parent 62b883467c
commit c80355f2bc
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import os
from django.core.management import call_command
from corres2math.tokens import email_validation_token
from django.contrib.auth.models import User
from django.test import TestCase
@ -279,6 +281,26 @@ class TestRegistration(TestCase):
self.assertRedirects(response, reverse("index"), 302, 200)
self.assertFalse("_fake_user_id" in self.client.session)
def test_research(self):
"""
Try to search some things.
"""
call_command("rebuild_index", "--noinput", "-v", 0)
response = self.client.get(reverse("haystack_search") + "?q=" + self.user.email)
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])
response = self.client.get(reverse("haystack_search") + "?q=" +
str(self.coach.registration.professional_activity))
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])
response = self.client.get(reverse("haystack_search") + "?q=" +
self.student.registration.get_student_class_display())
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])
def test_string_render(self):
# TODO These string field tests will be removed when used in a template
self.assertRaises(NotImplementedError, lambda: Registration().type)

View File

@ -6,7 +6,6 @@
<h2>{% trans "Search" %}</h2>
<form>
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
</form>