def _get_source_dict(self): '''Not only returns a source_dict, but creates the HarvestSource object as well - suitable for testing update actions. ''' source = HarvestSourceActionBase._get_source_dict(self) source = factories.HarvestSource(**source) # delete status because it gets in the way of the status supplied to # call_action_api later on. It is only a generated value, not affecting # the update/patch anyway. del source['status'] return source
def test_harvest_job_create_as_sysadmin(self): source = factories.HarvestSource(**SOURCE_DICT.copy()) site_user = toolkit.get_action('get_site_user')( {'model': model, 'ignore_auth': True}, {})['name'] data_dict = { 'source_id': source['id'], 'run': True } job = toolkit.get_action('harvest_job_create')( {'user': site_user}, data_dict) assert_equal(job['source_id'], source['id']) assert_equal(job['status'], 'Running') assert_equal(job['gather_started'], None) assert_in('stats', job.keys())
def test_harvest_job_create_as_admin(self): # as if an admin user presses 'refresh' user = ckan_factories.User() user['capacity'] = 'admin' org = ckan_factories.Organization(users=[user]) source_dict = dict(SOURCE_DICT.items() + [('publisher_id', org['id'])]) source = factories.HarvestSource(**source_dict) data_dict = {'source_id': source['id'], 'run': True} job = toolkit.get_action('harvest_job_create')({ 'user': user['name'] }, data_dict) assert_equal(job['source_id'], source['id']) assert_equal(job['status'], 'Running') assert_equal(job['gather_started'], None) assert_in('stats', job.keys())