当前位置: 首页>>代码示例>>Python>>正文


Python helpers.call_action方法代码示例

本文整理汇总了Python中ckan.tests.helpers.call_action方法的典型用法代码示例。如果您正苦于以下问题:Python helpers.call_action方法的具体用法?Python helpers.call_action怎么用?Python helpers.call_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ckan.tests.helpers的用法示例。


在下文中一共展示了helpers.call_action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_job_run_valid_stores_status_in_resource

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_job_run_valid_stores_status_in_resource(self, mock_validate):

        resource = factories.Resource(
            url='http://example.com/file.csv', format='csv')

        run_validation_job(resource)

        validation = Session.query(Validation).filter(
            Validation.resource_id == resource['id']).one()

        updated_resource = call_action('resource_show', id=resource['id'])

        assert_equals(updated_resource['validation_status'], validation.status)
        assert_equals(
            updated_resource['validation_timestamp'],
            validation.finished.isoformat()) 
开发者ID:frictionlessdata,项目名称:ckanext-validation,代码行数:18,代码来源:test_jobs.py

示例2: _create_harvest_source

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def _create_harvest_source(self, mock_url, **kwargs):

        source_dict = {
            'title': 'Test RDF DCAT Source',
            'name': 'test-rdf-dcat-source',
            'url': mock_url,
            'source_type': 'dcat_rdf',
        }

        source_dict.update(**kwargs)

        harvest_source = h.call_action('harvest_source_create',
                                       {}, **source_dict)

        eq_(harvest_source['source_type'], 'dcat_rdf')

        return harvest_source 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:19,代码来源:test_harvester.py

示例3: _test_harvest_create

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def _test_harvest_create(self, url, content, content_type, **kwargs):

        # Mock the GET request to get the file
        httpretty.register_uri(httpretty.GET, url,
                               body=content, content_type=content_type)

        # The harvester will try to do a HEAD request first so we need to mock
        # this as well
        httpretty.register_uri(httpretty.HEAD, url,
                               status=405, content_type=content_type)

        harvest_source = self._create_harvest_source(url, **kwargs)

        self._run_full_job(harvest_source['id'], num_objects=2)

        # Check that two datasets were created
        fq = "+type:dataset harvest_source_id:{0}".format(harvest_source['id'])
        results = h.call_action('package_search', {}, fq=fq)

        eq_(results['count'], 2)
        for result in results['results']:
            assert result['title'] in ('Example dataset 1',
                                       'Example dataset 2') 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:25,代码来源:test_harvester.py

示例4: test_resource_controller_plugin_create

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_resource_controller_plugin_create(self):
        user = factories.Sysadmin()
        package = factories.Dataset(user=user)

        # Set up the plugin
        ckan.plugins.load('example_iresourcecontroller')
        plugin = ckan.plugins.get_plugin('example_iresourcecontroller')

        res = helpers.call_action('resource_create',
                                  package_id=package['id'],
                                  name='test-resource',
                                  url='http://resource.create/',
                                  apikey=user['apikey'])

        assert plugin.counter['before_create'] == 1, plugin.counter
        assert plugin.counter['after_create'] == 1, plugin.counter
        assert plugin.counter['before_update'] == 0, plugin.counter
        assert plugin.counter['after_update'] == 0, plugin.counter
        assert plugin.counter['before_delete'] == 0, plugin.counter
        assert plugin.counter['after_delete'] == 0, plugin.counter 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:test_example_iresourcecontroller.py

示例5: test_resource_controller_plugin_update

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_resource_controller_plugin_update(self):
        user = factories.Sysadmin()
        resource = factories.Resource(user=user)

        # Set up the plugin here because we don't want the resource creation
        # to affect it (because we will only check for changes to update)
        ckan.plugins.load('example_iresourcecontroller')
        plugin = ckan.plugins.get_plugin('example_iresourcecontroller')

        res = helpers.call_action('resource_update',
                                  id=resource['id'],
                                  url='http://resource.updated/',
                                  apikey=user['apikey'])

        assert plugin.counter['before_create'] == 0, plugin.counter
        assert plugin.counter['after_create'] == 0, plugin.counter
        assert plugin.counter['before_update'] == 1, plugin.counter
        assert plugin.counter['after_update'] == 1, plugin.counter
        assert plugin.counter['before_delete'] == 0, plugin.counter
        assert plugin.counter['after_delete'] == 0, plugin.counter 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:test_example_iresourcecontroller.py

示例6: test_resource_controller_plugin_delete

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_resource_controller_plugin_delete(self):
        user = factories.Sysadmin()
        resource = factories.Resource(user=user)

        # Set up the plugin here because we don't want the resource creation
        # to affect it (because we will only check for changes to delete)
        ckan.plugins.load('example_iresourcecontroller')
        plugin = ckan.plugins.get_plugin('example_iresourcecontroller')

        res = helpers.call_action('resource_delete',
                                  id=resource['id'],
                                  apikey=user['apikey'])

        assert plugin.counter['before_create'] == 0, plugin.counter
        assert plugin.counter['after_create'] == 0, plugin.counter
        assert plugin.counter['before_update'] == 0, plugin.counter
        assert plugin.counter['after_update'] == 0, plugin.counter
        assert plugin.counter['before_delete'] == 1, plugin.counter
        assert plugin.counter['after_delete'] == 1, plugin.counter 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:test_example_iresourcecontroller.py

示例7: test_update_registered_core_value

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_update_registered_core_value(self):

        key = 'ckan.datasets_per_page'
        value = 5

        params = {key: value}

        assert_equals(config[key], self._datasets_per_page_original_value)

        new_config = helpers.call_action('config_option_update', **params)

        # output
        assert_equals(new_config[key], value)

        # config
        assert_equals(config[key], value)

        # app_globals
        globals_key = app_globals.get_globals_key(key)
        assert hasattr(app_globals.app_globals, globals_key)

        # db
        obj = model.Session.query(model.SystemInfo).filter_by(key=key).first()
        assert_equals(obj.value, unicode(value))  # all values stored as string 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:26,代码来源:test_iconfigurer_update_config.py

示例8: test_update_registered_external_value

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_update_registered_external_value(self):

        key = 'ckanext.example_iconfigurer.test_conf'
        value = 'Test value'

        params = {key: value}

        assert key not in config

        new_config = helpers.call_action('config_option_update', **params)

        # output
        assert_equals(new_config[key], value)

        # config
        assert_equals(config[key], value)

        # db
        obj = model.Session.query(model.SystemInfo).filter_by(key=key).first()
        assert_equals(obj.value, value)

        # not set in globals
        globals_key = app_globals.get_globals_key(key)
        assert not hasattr(app_globals.app_globals, globals_key) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:26,代码来源:test_iconfigurer_update_config.py

示例9: test_update_registered_external_value_in_show

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_update_registered_external_value_in_show(self):
        '''Registering an external key/value will allow it to be shown by the
        config_option_show action.'''

        key = 'ckanext.example_iconfigurer.test_conf'
        value = 'Test value'
        params = {key: value}

        # add registered external value
        helpers.call_action('config_option_update', **params)

        show_value = helpers.call_action(
            'config_option_show',
            key='ckanext.example_iconfigurer.test_conf')

        assert show_value == value 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:18,代码来源:test_iconfigurer_update_config.py

示例10: test_create_datastore_only_view

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_create_datastore_only_view(self):
        dataset = factories.Dataset()
        data = {
            'resource': {'package_id': dataset['id']},
            'fields': [{'id': 'a'}, {'id': 'b'}],
            'records': [{'a': 1, 'b': 'xyz'}, {'a': 2, 'b': 'zzz'}]
        }
        result = helpers.call_action('datastore_create', **data)

        resource_id = result['resource_id']

        url = h.url_for(controller='package', action='resource_read',
                        id=dataset['id'], resource_id=resource_id)

        result = self.app.get(url)

        assert 'data-module="data-viewer"' in result.body 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:19,代码来源:test_view.py

示例11: test_fts_on_field_calculates_ranks_only_on_that_specific_field

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_fts_on_field_calculates_ranks_only_on_that_specific_field(self):
        resource = factories.Resource()
        data = {
            'resource_id': resource['id'],
            'force': True,
            'records': [
                {'from': 'Brazil', 'to': 'Brazil'},
                {'from': 'Brazil', 'to': 'Italy'}
            ],
        }
        result = helpers.call_action('datastore_create', **data)
        search_data = {
            'resource_id': resource['id'],
            'fields': 'from',
            'q': {
                'from': 'Brazil'
            },
        }
        result = helpers.call_action('datastore_search', **search_data)
        ranks = [r['rank from'] for r in result['records']]
        assert_equals(len(result['records']), 2)
        assert_equals(len(set(ranks)), 1) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:24,代码来源:test_search.py

示例12: test_fts_works_on_non_textual_fields

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_fts_works_on_non_textual_fields(self):
        resource = factories.Resource()
        data = {
            'resource_id': resource['id'],
            'force': True,
            'records': [
                {'from': 'Brazil', 'year': {'foo': 2014}},
                {'from': 'Brazil', 'year': {'foo': 1986}}
            ],
        }
        result = helpers.call_action('datastore_create', **data)
        search_data = {
            'resource_id': resource['id'],
            'fields': 'year',
            'plain': False,
            'q': {
                'year': '20:*'
            },
        }
        result = helpers.call_action('datastore_search', **search_data)
        assert_equals(len(result['records']), 1)
        assert_equals(result['records'][0]['year'], {'foo': 2014}) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:24,代码来源:test_search.py

示例13: test_datastore_search_insecure_filter

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_datastore_search_insecure_filter(self):
        records = [
            {'age': 20}, {'age': 30}, {'age': 40}
        ]
        resource = self._create_datastore_resource(records)
        sql_inject = '1=1); DELETE FROM "%s"; COMMIT; SELECT * FROM "%s";--' \
                     % (resource['id'], resource['id'])
        filters = {
            'insecure_filter': sql_inject
        }

        assert_raises(p.toolkit.ValidationError,
                      helpers.call_action, 'datastore_search',
                      resource_id=resource['id'], filters=filters)

        result = helpers.call_action('datastore_search',
                                     resource_id=resource['id'])

        assert result['total'] == 3, result 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:test_interface.py

示例14: test_datastore_delete_can_create_custom_filters

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_datastore_delete_can_create_custom_filters(self):
        records = [
            {'age': 20}, {'age': 30}, {'age': 40}
        ]
        resource = self._create_datastore_resource(records)
        filters = {'age_between': [25, 35]}

        helpers.call_action('datastore_delete',
                            resource_id=resource['id'],
                            force=True,
                            filters=filters)

        result = helpers.call_action('datastore_search',
                                     resource_id=resource['id'])

        new_records_ages = [r['age'] for r in result['records']]
        new_records_ages.sort()
        assert_equals(new_records_ages, [20, 40]) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:test_interface.py

示例15: test_datastore_delete_insecure_filter

# 需要导入模块: from ckan.tests import helpers [as 别名]
# 或者: from ckan.tests.helpers import call_action [as 别名]
def test_datastore_delete_insecure_filter(self):
        records = [
            {'age': 20}, {'age': 30}, {'age': 40}
        ]
        resource = self._create_datastore_resource(records)
        sql_inject = '1=1); DELETE FROM "%s"; SELECT * FROM "%s";--' \
                     % (resource['id'], resource['id'])
        filters = {
            'age': 20,
            'insecure_filter': sql_inject
        }

        assert_raises(p.toolkit.ValidationError,
                      helpers.call_action, 'datastore_delete',
                      resource_id=resource['id'], force=True,
                      filters=filters)

        result = helpers.call_action('datastore_search',
                                     resource_id=resource['id'])

        assert result['total'] == 3, result 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:23,代码来源:test_interface.py


注:本文中的ckan.tests.helpers.call_action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。