diff --git a/ckanext/harvest/harvesters/base.py b/ckanext/harvest/harvesters/base.py index 6f5e08ef5..64f08a9aa 100644 --- a/ckanext/harvest/harvesters/base.py +++ b/ckanext/harvest/harvesters/base.py @@ -219,7 +219,7 @@ def _create_harvest_objects(self, remote_ids, harvest_job): def _create_or_update_package(self, package_dict, harvest_object, package_dict_form='rest'): ''' - Creates a new package or updates an exisiting one according to the + Creates a new package or updates an existing one according to the package dictionary provided. The package dictionary can be in one of two forms: diff --git a/ckanext/harvest/tests/harvesters/test_ckanharvester.py b/ckanext/harvest/tests/harvesters/test_ckanharvester.py index a7c012607..29eb600bb 100644 --- a/ckanext/harvest/tests/harvesters/test_ckanharvester.py +++ b/ckanext/harvest/tests/harvesters/test_ckanharvester.py @@ -1,6 +1,6 @@ import copy -from nose.tools import assert_equal, assert_raises +from nose.tools import assert_equal, assert_raises, assert_in import json from mock import patch, MagicMock @@ -235,11 +235,13 @@ def test_default_tags(self): def test_default_tags_invalid(self): config = {'default_tags': ['geo']} # should be list of dicts - assert_raises( - run_harvest, - url='http://localhost:%s' % mock_ckan.PORT, - harvester=CKANHarvester(), - config=json.dumps(config)) + with assert_raises(toolkit.ValidationError) as harvest_context: + run_harvest( + url='http://localhost:%s' % mock_ckan.PORT, + harvester=CKANHarvester(), + config=json.dumps(config)) + assert_in('default_tags must be a list of dictionaries', + str(harvest_context.exception)) def test_default_groups(self): Group(id='group1-id', name='group1') @@ -271,12 +273,14 @@ def test_default_groups_invalid(self): Group(id='group2-id', name='group2') # should be list of strings - config = {'default_tags': [{'name': 'group2'}]} - assert_raises( - run_harvest, - url='http://localhost:%s' % mock_ckan.PORT, - harvester=CKANHarvester(), - config=json.dumps(config)) + config = {'default_groups': [{'name': 'group2'}]} + with assert_raises(toolkit.ValidationError) as harvest_context: + run_harvest( + url='http://localhost:%s' % mock_ckan.PORT, + harvester=CKANHarvester(), + config=json.dumps(config)) + assert_in('default_groups must be a list of group names/ids', + str(harvest_context.exception)) def test_default_extras(self): config = { @@ -307,8 +311,10 @@ def test_default_extras_invalid(self): config = { 'default_extras': 'utf8', # value should be a dict } - assert_raises( - run_harvest, - url='http://localhost:%s' % mock_ckan.PORT, - harvester=CKANHarvester(), - config=json.dumps(config)) \ No newline at end of file + with assert_raises(toolkit.ValidationError) as harvest_context: + run_harvest( + url='http://localhost:%s' % mock_ckan.PORT, + harvester=CKANHarvester(), + config=json.dumps(config)) + assert_in('default_extras must be a dictionary', + str(harvest_context.exception))