You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from django.test import TestCase, Client
  2. from django.core.urlresolvers import reverse
  3. from django.core import management
  4. from haystack import backend
  5. class SuggestViewTest(TestCase):
  6. fixtures = ['sample-products']
  7. def setUp(self):
  8. #clear out existing index without prompting user and ensure that
  9. #fixtures are indexed
  10. self.client = Client()
  11. sb = backend.SearchBackend()
  12. sb.clear()
  13. management.call_command('update_index', verbosity=0) #silenced
  14. def test_term_in_fixtures_found(self):
  15. url = reverse('oscar-search-suggest')
  16. response = self.client.get(url, {'query_term': 'Pint'})
  17. self.assertEquals(200, response.status_code)
  18. self.assertTrue('Pint' in response.content) #ensuring we actually find a result in the response
  19. class MultiFacetedSearchViewTest(TestCase):
  20. fixtures = ['sample-products']
  21. def setUp(self):
  22. #clear out existing index without prompting user and ensure that
  23. #fixtures are indexed
  24. self.client = Client()
  25. sb = backend.SearchBackend()
  26. sb.clear()
  27. management.call_command('update_index', verbosity=0) #silenced
  28. def test_with_query(self):
  29. url = reverse('oscar-search')
  30. response = self.client.get(url, {'q': 'Pint'})
  31. self.assertEquals(200, response.status_code)
  32. self.assertTrue('value="Pint"' in response.content) #ensuring query field is set