Question

I am using Django 1.4, Django-Haystack 2.0 and Solr (pysolr 2.0.15). I have to write test cases in Django for Haystack. I have written indexes for the models and defined some functions like index_queryset. So, now I am in a fix on how to write test cases for the same.

Was it helpful?

Solution

Well - if you are not using some special pysolr features (like proximity search) I suggest to use Simple backend in testing. You probably do not want to test how Haystack with pysolr works, because it is already tested and it is search, which is hard to predict all results and just will take long if you want to remove and build indexes often in tests.

You probably just want to test what you have written, e.g. those index_queryset function or maybe some prepare_* functions you added - test them completely separately (what is given and what they returns), just as unit tests should do - without any pysolr related stuff.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top