Skip to content

Commit

Permalink
[#1651] Avoid testing with httpretty + Solr on Python 2.6
Browse files Browse the repository at this point in the history
When running on Python 2.6, httpretty doesn't play nice with Solr (it
causes read timeouts). The tests are still run but we avoid using Solr,
either by using `use_cache`=False on `package_show` or disabling the
automatic indexing of datatasets when running on Python 2.6.
  • Loading branch information
amercader committed Nov 10, 2015
1 parent 5f68e7e commit 7b83c94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ckanext/datapusher/tests/test.py
Expand Up @@ -47,11 +47,21 @@ def setup_class(cls):
set_url_type(
model.Package.get('annakarenina').resources, cls.sysadmin_user)

# Httpretty crashes with Solr on Python 2.6, disable the automatic
# Solr indexing
if (sys.version_info[0] == 2 and sys.version_info[1] == 6
and p.plugin_loaded('synchronous_search')):
p.unload('synchronous_search')

@classmethod
def teardown_class(cls):
rebuild_all_dbs(cls.Session)
p.unload('datastore')
p.unload('datapusher')
# Reenable Solr indexing
if (sys.version_info[0] == 2 and sys.version_info[1] == 6
and not p.plugin_loaded('synchronous_search')):
p.load('synchronous_search')

def test_create_ckan_resource_in_package(self):
package = model.Package.get('annakarenina')
Expand Down
15 changes: 14 additions & 1 deletion ckanext/resourceproxy/tests/test_proxy.py
@@ -1,3 +1,4 @@
import sys
import requests
import unittest
import json
Expand Down Expand Up @@ -27,7 +28,8 @@ def set_resource_url(url):
context = {
'model': model,
'session': model.Session,
'user': model.User.get('testsysadmin').name
'user': model.User.get('testsysadmin').name,
'use_cache': False,
}

resource = p.toolkit.get_action('resource_show')(
Expand Down Expand Up @@ -55,12 +57,23 @@ def setup_class(cls):
wsgiapp = middleware.make_app(config['global_conf'], **config)
cls.app = paste.fixture.TestApp(wsgiapp)
create_test_data.CreateTestData.create()
# Httpretty crashes with Solr on Python 2.6, disable the automatic
# Solr indexing
if (sys.version_info[0] == 2 and sys.version_info[1] == 6
and p.plugin_loaded('synchronous_search')):
p.unload('synchronous_search')


@classmethod
def teardown_class(cls):
config.clear()
config.update(cls._original_config)
model.repo.rebuild_db()
# Reenable Solr indexing
if (sys.version_info[0] == 2 and sys.version_info[1] == 6
and not p.plugin_loaded('synchronous_search')):
p.load('synchronous_search')


def setUp(self):
self.url = 'http://www.ckan.org/static/example.json'
Expand Down

0 comments on commit 7b83c94

Please sign in to comment.