Use smaller pagination in test.

This commit is contained in:
Roberto Rosario
2015-07-11 17:20:45 -04:00
parent 7c95431066
commit 53c631b505

View File

@@ -3,8 +3,9 @@ from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.core.files.base import File
from django.core.urlresolvers import reverse
from django.test.client import Client
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
from documents.models import DocumentType
from documents.search import document_search
@@ -27,11 +28,11 @@ class Issue46TestCase(TestCase):
self.assertTrue(logged_in)
self.assertTrue(self.admin_user.is_authenticated())
self.document_count = 30
self.document_count = 4
self.document_type = DocumentType.objects.create(label=TEST_DOCUMENT_TYPE)
# Upload 30 instances of the same test document
# Upload 50 instances of the same test document
for i in range(self.document_count):
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
self.document_type.new_document(
@@ -39,6 +40,7 @@ class Issue46TestCase(TestCase):
label='test document',
)
@override_settings(PAGINATION_DEFAULT_PAGINATION=2)
def test_advanced_search_past_first_page(self):
# Make sure all documents are returned by the search
model_list, result_set, elapsed_time = document_search.search({'label': 'test document'}, user=self.admin_user)
@@ -46,8 +48,8 @@ class Issue46TestCase(TestCase):
# Funcitonal test for the first page of advanced results
response = self.client.get(reverse('search:results'), {'label': 'test'})
self.assertContains(response, 'Total (1 - 20 out of 30) (Page 1 of 2)', status_code=200)
self.assertContains(response, 'Total (1 - 2 out of 4) (Page 1 of 2)', status_code=200)
# Functional test for the second page of advanced results
response = self.client.get(reverse('search:results'), {'label': 'test', 'page': 2})
self.assertContains(response, 'Total (21 - 30 out of 30) (Page 2 of 2)', status_code=200)
self.assertContains(response, 'Total (3 - 4 out of 4) (Page 2 of 2)', status_code=200)