You can run the tests with:
./run_tests.py
This will run all the tests.
Note
If you need to adjust the settings, copy test_settings.py to a new file (like test_settings_local.py), edit the file, and specify that as the value for the environment variable DJANGO_SETTINGS_MODULE.
DJANGO_SETTINGS_MODULE=test_settings_local ./run_tests.py
This is helpful if you need to change the value of ES_HOSTS to match the ip address or port that elasticsearch is listening on.
Tests are located in elasticutils/tests/.
We use nose for test utilities and running tests.
If you’re testing things in ElasticUtils that require hitting an Elasticsearch cluster, then you should subclass elasticutils.tests.ESTestCase which has code in it for making things easier.
Superclass for Elasticsearch-using test cases.
Property index_name: | |
---|---|
name of the index to use | |
Property mapping_type_name: | |
the mapping type name | |
Property es_settings: | |
settings to use to build a pyelasticsearch ElasticSearch object. | |
Property mapping: | |
the mapping to use when creating an index | |
Property data: | any data to add to the index in setup_class |
Property skip_tests: | |
if Elasticsearch isn’t available, then this is True and therefore tests should be skipped for this class |
For examples of usage, see the other test_*.py files.
Refresh index after indexing.
This refreshes the index specified by self.index_name.
Parameters: | timesleep – int; number of seconds to sleep after telling Elasticsearch to refresh |
---|
Set up a single test.
Raises SkipTest: | |
---|---|
if skip_tests is True for this class/instance |
Class setup for tests.
Checks to see if ES is running and if not, sets skip_test to True on the class.
Class tear down for tests.