From 7b83c947d9ef56e7cf3aba802ba4259817ac7866 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 10 Nov 2015 10:32:58 +0000 Subject: [PATCH] [#1651] Avoid testing with httpretty + Solr on Python 2.6 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. --- ckanext/datapusher/tests/test.py | 10 ++++++++++ ckanext/resourceproxy/tests/test_proxy.py | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ckanext/datapusher/tests/test.py b/ckanext/datapusher/tests/test.py index e951ec8c914..65150b1f7dc 100644 --- a/ckanext/datapusher/tests/test.py +++ b/ckanext/datapusher/tests/test.py @@ -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') diff --git a/ckanext/resourceproxy/tests/test_proxy.py b/ckanext/resourceproxy/tests/test_proxy.py index 89f839af595..b461dbc9eb0 100644 --- a/ckanext/resourceproxy/tests/test_proxy.py +++ b/ckanext/resourceproxy/tests/test_proxy.py @@ -1,3 +1,4 @@ +import sys import requests import unittest import json @@ -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')( @@ -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'