Beispiel #1
0
    def test_harvest_source_create_twice_with_unique_url_and_config(self):
        data_dict = SOURCE_DICT.copy()
        factories.HarvestSourceObj(**data_dict)

        site_user = toolkit.get_action('get_site_user')({
            'model': model,
            'ignore_auth': True
        }, {})['name']
        data_dict['name'] = 'another-source'
        data_dict['config'] = '{"something": "new"}'
        toolkit.get_action('harvest_source_create')({
            'user': site_user
        }, data_dict)
Beispiel #2
0
    def test_harvest_source_clear(self):
        source = factories.HarvestSourceObj(**SOURCE_DICT.copy())
        job = factories.HarvestJobObj(source=source)
        dataset = ckan_factories.Dataset()
        object_ = factories.HarvestObjectObj(job=job, source=source,
                                             package_id=dataset['id'])

        context = {'model': model, 'session': model.Session,
                   'ignore_auth': True, 'user': ''}
        result = toolkit.get_action('harvest_source_clear')(
            context, {'id': source.id})

        assert_equal(result, {'id': source.id})
        source = harvest_model.HarvestSource.get(source.id)
        assert source
        assert_equal(harvest_model.HarvestJob.get(job.id), None)
        assert_equal(harvest_model.HarvestObject.get(object_.id), None)
        assert_equal(model.Package.get(dataset['id']), None)
Beispiel #3
0
    def test_create_bad_parameters(self):
        source_a = factories.HarvestSourceObj()
        job = factories.HarvestJobObj()

        context = {
            'model': model,
            'session': model.Session,
            'ignore_auth': True,
        }
        data_dict = {'job_id': job.id, 'source_id': source_a.id, 'extras': 1}
        harvest_object_create = toolkit.get_action('harvest_object_create')
        self.assertRaises(toolkit.ValidationError, harvest_object_create,
                          context, data_dict)

        data_dict['extras'] = {'test': 1}

        self.assertRaises(toolkit.ValidationError, harvest_object_create,
                          context, data_dict)