Changeset - 1ed2e7271e03
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2016-02-03 22:21:31
thomas.de.schampheleire@gmail.com
tests: search: fix always-skipped empty-search-index test

The test that verifies the output when the search index is empty is always
skipped when following the standard development setup, so is useless.

Instead, fix the test by mocking the configuration, pointing the search
index to a valid location but without index.
1 file changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_search.py
Show inline comments
 
import mock
 
import os
 
from kallithea.tests import *
 

	
 

	
 
class TestSearchController(TestController):
 

	
 
@@ -9,16 +10,21 @@ class TestSearchController(TestControlle
 
        response = self.app.get(url(controller='search', action='index'))
 

	
 
        response.mustcontain('class="small" id="q" name="q" type="text"')
 
        # Test response...
 

	
 
    def test_empty_search(self):
 
        if os.path.isdir(self.index_location):
 
            raise SkipTest('skipped due to existing index')
 
        else:
 
            self.log_user()
 
        self.log_user()
 

	
 
        config_mock = {
 
            'app_conf': {
 
                # can be any existing dir that does not contain an actual index
 
                'index_dir': '.',
 
            }
 
        }
 
        with mock.patch('kallithea.controllers.search.config', config_mock):
 
            response = self.app.get(url(controller='search', action='index'),
 
                                    {'q': HG_REPO})
 
            response.mustcontain('There is no index to search in. '
 
                                 'Please run whoosh indexer')
 

	
 
    def test_normal_search(self):
0 comments (0 inline, 0 general)