From 0632a8b0756890c91ab69838f98f5bbe7fd3604e Mon Sep 17 00:00:00 2001 From: David Read Date: Thu, 8 Mar 2012 18:46:29 +0000 Subject: [PATCH 1/2] [tests]: Fix assert_in and assert_not_in imports - they needs Python 2.7, so have a fallback for Python 2.5 and 2.6. --- ckan/tests/__init__.py | 8 ++++++++ ckan/tests/functional/api/model/test_package.py | 12 ++++++++++++ ckan/tests/lib/test_dictization.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ckan/tests/__init__.py b/ckan/tests/__init__.py index c61f20ba92c..66132736b95 100644 --- a/ckan/tests/__init__.py +++ b/ckan/tests/__init__.py @@ -338,3 +338,11 @@ def skip_test(*args): def clear_flash(res=None): messages = _flash.pop_messages() + +try: + from nose.tools import assert_in, assert_not_in +except ImportError: + def assert_in(a, b): + assert a in b, '%r was not in %r' % (a, b) + def assert_not_in(a, b): + assert a not in b, '%r was in %r' % (a, b) diff --git a/ckan/tests/functional/api/model/test_package.py b/ckan/tests/functional/api/model/test_package.py index 9da65586940..447acc9332f 100644 --- a/ckan/tests/functional/api/model/test_package.py +++ b/ckan/tests/functional/api/model/test_package.py @@ -245,6 +245,18 @@ def test_register_post_bad_request(self): res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST, extra_environ=self.extra_environ) + def test_register_post_bad_request_2(self): + test_params = { + 'name':u'testpackage07_400', + 'extras':[ # should not be a list in here + {u'key': u'value} + ], + } + offset = self.offset('/rest/dataset') + postparams = '%s=1' % self.dumps(test_params) + res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST, + extra_environ=self.extra_environ) + def test_register_post_denied(self): offset = self.offset('/rest/dataset') postparams = '%s=1' % self.dumps(self.package_fixture_data) diff --git a/ckan/tests/lib/test_dictization.py b/ckan/tests/lib/test_dictization.py index 64d2e80f77c..93209d377db 100644 --- a/ckan/tests/lib/test_dictization.py +++ b/ckan/tests/lib/test_dictization.py @@ -1,4 +1,4 @@ -from nose.tools import assert_equal, assert_not_in, assert_in +from ckan.tests import assert_equal, assert_not_in, assert_in from pprint import pprint, pformat from difflib import unified_diff From cd373300cc31a451b25f4b6c651c350c71431ff1 Mon Sep 17 00:00:00 2001 From: David Read Date: Fri, 9 Mar 2012 18:11:03 +0000 Subject: [PATCH 2/2] [test]: I did not mean to commit this new test in the last commit. --- ckan/tests/functional/api/model/test_package.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ckan/tests/functional/api/model/test_package.py b/ckan/tests/functional/api/model/test_package.py index 447acc9332f..9da65586940 100644 --- a/ckan/tests/functional/api/model/test_package.py +++ b/ckan/tests/functional/api/model/test_package.py @@ -245,18 +245,6 @@ def test_register_post_bad_request(self): res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST, extra_environ=self.extra_environ) - def test_register_post_bad_request_2(self): - test_params = { - 'name':u'testpackage07_400', - 'extras':[ # should not be a list in here - {u'key': u'value} - ], - } - offset = self.offset('/rest/dataset') - postparams = '%s=1' % self.dumps(test_params) - res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST, - extra_environ=self.extra_environ) - def test_register_post_denied(self): offset = self.offset('/rest/dataset') postparams = '%s=1' % self.dumps(self.package_fixture_data)