コード例 #1
0
ファイル: test_search.py プロジェクト: Big-Data/ckan
 def setup_class(cls):
     p.load('datastore')
     ctd.CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
     cls.normal_user = model.User.get('annafan')
     resource = model.Package.get('annakarenina').resources[0]
     cls.data = dict(
         resource_id=resource.id,
         fields=[
           {'id': 'id'},
           {'id': 'date', 'type':'date'},
           {'id': 'x'},
           {'id': 'y'},
           {'id': 'z'},
           {'id': 'country'},
           {'id': 'title'},
           {'id': 'lat'},
           {'id': 'lon'}
         ],
         records=[
           {'id': 0, 'date': '2011-01-01', 'x': 1, 'y': 2, 'z': 3, 'country': 'DE', 'title': 'first', 'lat':52.56, 'lon':13.40},
           {'id': 1, 'date': '2011-02-02', 'x': 2, 'y': 4, 'z': 24, 'country': 'UK', 'title': 'second', 'lat':54.97, 'lon':-1.60},
           {'id': 2, 'date': '2011-03-03', 'x': 3, 'y': 6, 'z': 9, 'country': 'US', 'title': 'third', 'lat':40.00, 'lon':-75.5},
           {'id': 3, 'date': '2011-04-04', 'x': 4, 'y': 8, 'z': 6, 'country': 'UK', 'title': 'fourth', 'lat':57.27, 'lon':-6.20},
           {'id': 4, 'date': '2011-05-04', 'x': 5, 'y': 10, 'z': 15, 'country': 'UK', 'title': 'fifth', 'lat':51.58, 'lon':0},
           {'id': 5, 'date': '2011-06-02', 'x': 6, 'y': 12, 'z': 18, 'country': 'DE', 'title': 'sixth', 'lat':51.04, 'lon':7.9}
         ]
     )
     postparams = '%s=1' % json.dumps(cls.data)
     auth = {'Authorization': str(cls.sysadmin_user.apikey)}
     res = cls.app.post('/api/action/datastore_create', params=postparams,
                        extra_environ=auth)
     res_dict = json.loads(res.body)
     assert res_dict['success'] is True
コード例 #2
0
ファイル: test_upsert.py プロジェクト: 31H0B1eV/ckan
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'nested', 'type': 'json'},
                       {'id': 'characters', 'type': 'text[]'},
                       {'id': 'published'}],
            'primary_key': u'b\xfck',
            'records': [{u'b\xfck': 'annakarenina', 'author': 'tolstoy',
                        'published': '2005-03-01', 'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                        'nested': {'a':'b'}}
                       ]
            }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        import pylons
        engine = db._get_engine(
                None,
                {'connection_url': pylons.config['ckan.datastore.write_url']}
            )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #3
0
ファイル: cli.py プロジェクト: ArunEG/ckanext-dgu
    def command(self):
        self._load_config()
        self._setup_app()

        # Now we can import
        from ckan import plugins
        from ckanext.dgu.testtools.create_test_data import DguCreateTestData
        
        try:
            plugins.load('synchronous_search') # so packages get indexed
        except:
            pass

        self.log = logging.getLogger(__name__)

        if self.args:
            cmd = self.args[0]
        else:
            cmd = 'basic'
        if cmd == 'basic':
            DguCreateTestData.create_dgu_test_data()
        elif cmd == 'users':
            DguCreateTestData.create_dgu_test_users()
        else:
            print 'Command %s not recognized' % cmd
            raise NotImplementedError
        
        self.log.info('Created DGU test data successfully')
コード例 #4
0
ファイル: test_delete.py プロジェクト: 31H0B1eV/ckan
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'aliases': 'books2',
            'fields': [{'id': 'book', 'type': 'text'},
                       {'id': 'author', 'type': 'text'}],
            'records': [{'book': 'annakarenina', 'author': 'tolstoy'},
                        {'book': 'warandpeace', 'author': 'tolstoy'}]
        }

        #model.repo.rebuild_db()
        #model.repo.clean_db()

        import pylons
        engine = db._get_engine(
                None,
                {'connection_url': pylons.config['ckan.datastore.write_url']}
            )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #5
0
    def setup_class(cls):
        p.load('timeseries')
        helpers.reset_db()
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        engine = db._get_engine(
            {'connection_url': pylons.config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
        cls.dataset = model.Package.get('annakarenina')

        cls.data = {
            'resource_id': '',
            'force': True,
            'method': 'insert',
            'records': [{'author': 'tolstoy5',
                        'published': '2005-03-05'},
                        {'author': 'tolstoy6'},
                        {'author': 'tolstoy7',
                        'published': '2005-03-05'}
                       ]
        }

        cls.data['resource_id'] = cls.dataset.resources[0].id
        result = helpers.call_action('datastore_ts_create', **cls.data)

        cls.data['resource_id'] = cls.dataset.resources[1].id
        result = helpers.call_action('datastore_ts_create', **cls.data)

        datastore_test_helpers.set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
コード例 #6
0
ファイル: test_action.py プロジェクト: Ezio47/ckan
    def setup_class(cls):
        if not p.plugin_loaded('datastore'):
            p.load('datastore')
        if not p.plugin_loaded('datapusher'):
            p.load('datapusher')

        helpers.reset_db()
コード例 #7
0
    def setup_class(cls):
        harvest_model.setup()
        CreateTestData.create()

        sysadmin_user = ckan.model.User.get('testsysadmin')
        cls.sysadmin = {
                'id': sysadmin_user.id,
                'apikey': sysadmin_user.apikey,
                'name': sysadmin_user.name,
                }


        cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)

        cls.default_source_dict =  {
          "url": "http://test.action.com",
          "name": "test-source-action",
          "title": "Test source action",
          "notes": "Test source action desc",
          "source_type": "test-for-action",
          "frequency": "MANUAL",
          "config": json.dumps({"custom_option":["a","b"]})
        }

        if not p.plugin_loaded('test_action_harvester'):
            p.load('test_action_harvester')
コード例 #8
0
ファイル: test_plugins.py プロジェクト: 31H0B1eV/ckan
 def test_auth_plugin_override(self):
     plugins.load_all(config)
     package_list_original = new_authz.is_authorized('package_list', {})
     plugins.load('auth_plugin')
     assert new_authz.is_authorized('package_list', {}) != package_list_original
     plugins.unload('auth_plugin')
     assert new_authz.is_authorized('package_list', {}) == package_list_original
コード例 #9
0
ファイル: test_i18n.py プロジェクト: CIOIL/DataGovIL
    def test_translation_works_on_flask_and_pylons(self):

        app = helpers._get_test_app()
        if not p.plugin_loaded(u'test_routing_plugin'):
            p.load(u'test_routing_plugin')
        try:
            plugin = p.get_plugin(u'test_routing_plugin')
            app.flask_app.register_extension_blueprint(
                plugin.get_blueprint())

            resp = app.get(u'/flask_translated')

            eq_(resp.body, u'Dataset')

            resp = app.get(u'/es/flask_translated')

            eq_(resp.body, u'Conjunto de datos')

            resp = app.get(u'/pylons_translated')

            eq_(resp.body, u'Groups')

            resp = app.get(u'/es/pylons_translated')

            eq_(resp.body, u'Grupos')

        finally:

            if p.plugin_loaded(u'test_routing_plugin'):
                p.unload(u'test_routing_plugin')
コード例 #10
0
ファイル: test_dump.py プロジェクト: CodeandoMexico/ckan
    def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'aliases': 'books',
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'published'},
                       {'id': u'characters', u'type': u'_text'}],
            'records': [{u'b\xfck': 'annakarenina',
                        'author': 'tolstoy',
                        'published': '2005-03-01',
                        'nested': ['b', {'moo': 'moo'}],
                        u'characters': [u'Princess Anna', u'Sergius']},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                         'nested': {'a': 'b'}}]
        }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine({
            'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #11
0
ファイル: test_delete.py プロジェクト: DataShades/ckan
    def setup_class(cls):
        if not p.plugin_loaded('image_view'):
            p.load('image_view')
        if not p.plugin_loaded('recline_view'):
            p.load('recline_view')

        helpers.reset_db()
コード例 #12
0
ファイル: test_middleware.py プロジェクト: HatemAlSum/ckan
    def test_ask_around_pylons_extension_route_post_using_get(self):

        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()

        # We want our CKAN app, not the WebTest one
        app = app.app

        environ = {
            'PATH_INFO': '/from_pylons_extension_before_map_post_only',
            'REQUEST_METHOD': 'GET',
        }
        wsgiref.util.setup_testing_defaults(environ)

        answers = app.ask_around('can_handle_request', environ)

        # We are going to get an answer from Pylons, but just because it will
        # match the catch-all template route, hence the `core` origin.
        eq_(len(answers), 1)
        eq_(answers[0][0], True)
        eq_(answers[0][1], 'pylons_app')
        eq_(answers[0][2], 'core')

        p.unload('test_routing_plugin')
コード例 #13
0
ファイル: test_middleware.py プロジェクト: HatemAlSum/ckan
    def test_ask_around_flask_core_and_pylons_extension_route(self):

        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()

        # We want our CKAN app, not the WebTest one
        app = app.app

        environ = {
            'PATH_INFO': '/pylons_and_flask',
            'REQUEST_METHOD': 'GET',
        }
        wsgiref.util.setup_testing_defaults(environ)

        answers = app.ask_around('can_handle_request', environ)
        answers = sorted(answers, key=lambda a: a[1])

        eq_(len(answers), 2)
        eq_([a[0] for a in answers], [True, True])
        eq_([a[1] for a in answers], ['flask_app', 'pylons_app'])

        # TODO: we still can't distinguish between Flask core and extension
        # eq_(answers[0][2], 'extension')

        eq_(answers[1][2], 'extension')

        p.unload('test_routing_plugin')
コード例 #14
0
ファイル: test_environment.py プロジェクト: PublicaMundi/ckan
 def teardown(self):
     for env_var, _ in self.ENV_VAR_LIST:
         if os.environ.get(env_var, None):
             del os.environ[env_var]
     config.update(self._old_config)
     # plugin.load() will force the config to update
     p.load()
コード例 #15
0
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('timeseries')
        helpers.reset_db()

        # Creating 3 resources with 3 retention policies: 
        # to remove 10, 20 and 90% of data when the 
        # resource gets to its size limit
        cls.retention = [10, 90, 20, 50]
        cls.resource_ids = []

        package = factories.Dataset()
        for i, ret in enumerate(cls.retention):
            data = {
                'resource': {
                    'retention': cls.retention[i],
                    'package_id': package['id']
                },
            }
            result = helpers.call_action('datastore_ts_create', **data)
            cls.resource_ids.append(result['resource_id'])

        engine = db._get_engine(
                {'connection_url': pylons.config['ckan.datastore.write_url']}
            )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #16
0
ファイル: test_plugins.py プロジェクト: 31H0B1eV/ckan
 def test_action_plugin_override(self):
     plugins.load_all(config)
     status_show_original = logic.get_action('status_show')(None, {})
     plugins.load('action_plugin')
     assert logic.get_action('status_show')(None, {}) != status_show_original
     plugins.unload('action_plugin')
     assert logic.get_action('status_show')(None, {}) == status_show_original
def main():
    parser = argparse.ArgumentParser(description = __doc__)
    parser.add_argument('config', help = 'path of configuration file')
    parser.add_argument('-v', '--verbose', action = 'store_true', help = 'increase output verbosity')

    args = parser.parse_args()
#    logging.basicConfig(level = logging.DEBUG if args.verbose else logging.WARNING, stream = sys.stdout)
    logging.basicConfig(level = logging.INFO if args.verbose else logging.WARNING, stream = sys.stdout)
    site_conf = appconfig('config:{}'.format(os.path.abspath(args.config)))
    load_environment(site_conf.global_conf, site_conf.local_conf)

    registry = Registry()
    registry.prepare()
    registry.register(pylons.translator, MockTranslator())

    plugins.load('synchronous_search')

    model.repo.new_revision()

    for package_extra in model.Session.query(model.PackageExtra).filter(
            model.PackageExtra.key == 'territorial_coverage_granularity',
            model.PackageExtra.value == 'france',
            ):
        package = package_extra.package
        if package.private or package.state != 'active':
            log.warning(u'Territorial coverage granularity of package {} must be manually corrected'.format(
                package.name))
            continue
        package_extra.value = 'pays'

    model.repo.commit_and_remove()

    return 0
コード例 #18
0
ファイル: __init__.py プロジェクト: netconstructor/ckan
def setup_test_search_index():
    from ckan import plugins

    if not is_search_supported():
        raise SkipTest("Search not supported")
    search.clear()
    plugins.load("synchronous_search")
コード例 #19
0
def main():
    parser = argparse.ArgumentParser(description = __doc__)
    parser.add_argument('config', help = 'path of configuration file')
    parser.add_argument('-v', '--verbose', action = 'store_true', help = 'increase output verbosity')

    args = parser.parse_args()
#    logging.basicConfig(level = logging.DEBUG if args.verbose else logging.WARNING, stream = sys.stdout)
    logging.basicConfig(level = logging.INFO if args.verbose else logging.WARNING, stream = sys.stdout)
    site_conf = appconfig('config:{}'.format(os.path.abspath(args.config)))
    load_environment(site_conf.global_conf, site_conf.local_conf)

    registry = Registry()
    registry.prepare()
    registry.register(pylons.translator, MockTranslator())

    plugins.load('synchronous_search')

    model.repo.new_revision()

    for package_extra in model.Session.query(model.PackageExtra).filter(
            model.PackageExtra.key == 'supplier_id',
            model.PackageExtra.package_id.in_(
                model.Session.query(model.Package.id).filter(model.Package.name.like('%-fork-%'))),
            ):
        model.Session.delete(package_extra)

    model.repo.commit_and_remove()

    return 0
コード例 #20
0
    def setup_class(cls):
        p.load("datastore")
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get("testsysadmin")
        cls.normal_user = model.User.get("annafan")
        resource = model.Package.get("annakarenina").resources[0]
        cls.data = {
            "resource_id": resource.id,
            "fields": [{"id": u"b\xfck", "type": "text"}, {"id": "author", "type": "text"}, {"id": "published"}],
            "records": [
                {
                    u"b\xfck": "annakarenina",
                    "author": "tolstoy",
                    "published": "2005-03-01",
                    "nested": ["b", {"moo": "moo"}],
                },
                {u"b\xfck": "warandpeace", "author": "tolstoy", "nested": {"a": "b"}},
            ],
        }
        postparams = "%s=1" % json.dumps(cls.data)
        auth = {"Authorization": str(cls.sysadmin_user.apikey)}
        res = cls.app.post("/api/action/datastore_create", params=postparams, extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict["success"] is True

        cls.expected_records = [
            {
                u"published": u"2005-03-01T00:00:00",
                u"_id": 1,
                u"nested": [u"b", {u"moo": u"moo"}],
                u"b\xfck": u"annakarenina",
                u"author": u"tolstoy",
            },
            {u"published": None, u"_id": 2, u"nested": {u"a": u"b"}, u"b\xfck": u"warandpeace", u"author": u"tolstoy"},
        ]
コード例 #21
0
    def setup_class(cls):
        CreateTestData.create('publisher')
        model.repo.new_revision()

        usr = model.User(name="ectest", apikey="ectest", password=u'ectest')
        model.Session.add(usr)
        model.Session.commit()

        g = model.Group.get('david')
        g.type = 'organization'
        model.Session.add(g)

        p = model.Package.get('warandpeace')
        mu = model.Member(table_id=usr.id, table_name='user', group=g)
        mp = model.Member(table_id=p.id, table_name='package', group=g)
        model.Session.add(mu)
        model.Session.add(mp)
        model.Session.commit()

        cls.sysadmin_user = model.User.get('testsysadmin')

        status = create_vocab(u'status', cls.sysadmin_user.name)
        add_tag_to_vocab(u'http://purl.org/adms/status/Completed',
                         status['id'], cls.sysadmin_user.name)

        plugins.load('ecportal')
コード例 #22
0
    def setup_class(cls):
        if not p.plugin_loaded("image_view"):
            p.load("image_view")
        if not p.plugin_loaded("recline_view"):
            p.load("recline_view")

        helpers.reset_db()
コード例 #23
0
ファイル: test_delete.py プロジェクト: mxabierto/ckan
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        cls.app = helpers._get_test_app()
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'aliases': u'b\xfck2',
            'fields': [{'id': 'book', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'rating with %', 'type': 'text'}],
            'records': [{'book': 'annakarenina', 'author': 'tolstoy',
                         'rating with %': '90%'},
                        {'book': 'warandpeace', 'author': 'tolstoy',
                         'rating with %': '42%'}]
        }

        engine = db.get_write_engine()

        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
コード例 #24
0
ファイル: test_package.py プロジェクト: Hoedic/ckan
    def setup_class(cls):
        super(cls, cls).setup_class()

        if not p.plugin_loaded('image_view'):
            p.load('image_view')

        helpers.reset_db()
コード例 #25
0
ファイル: test_none_root.py プロジェクト: CIOIL/DataGovIL
 def test_resource_url(self):
     app = helpers._get_test_app()
     p.load(u'example_theme_v15_fanstatic')
     content = app.get(u'/en/base.html')
     assert u'example_theme.css' in content
     assert u'href="/data/fanstatic/example_theme' in content
     p.unload(u'example_theme_v15_fanstatic')
コード例 #26
0
ファイル: test_api.py プロジェクト: ViderumGlobal/ckan
    def test_api_info(self):

        dataset = factories.Dataset()
        resource = factories.Resource(
            id='588dfa82-760c-45a2-b78a-e3bc314a4a9b',
            package_id=dataset['id'], datastore_active=True)

        # the 'API info' is seen on the resource_read page, a snippet loaded by
        # javascript via data_api_button.html
        url = template_helpers.url_for(
            controller='api', action='snippet', ver=1,
            snippet_path='api_info.html', resource_id=resource['id'])

        if not p.plugin_loaded('datastore'):
            p.load('datastore')
        app = self._get_test_app()
        page = app.get(url, status=200)
        p.unload('datastore')

        # check we built all the urls ok
        expected_urls = (
            'http://test.ckan.net/api/3/action/datastore_create',
            'http://test.ckan.net/api/3/action/datastore_upsert',
            '<code>http://test.ckan.net/api/3/action/datastore_search',
            'http://test.ckan.net/api/3/action/datastore_search_sql',
            'http://test.ckan.net/api/3/action/datastore_search?resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b&amp;limit=5',
            'http://test.ckan.net/api/3/action/datastore_search?resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b&amp;q=jones',
            'http://test.ckan.net/api/3/action/datastore_search_sql?sql=SELECT * from &#34;588dfa82-760c-45a2-b78a-e3bc314a4a9b&#34; WHERE title LIKE &#39;jones&#39;',
            "url: 'http://test.ckan.net/api/3/action/datastore_search'",
            "http://test.ckan.net/api/3/action/datastore_search?resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b&amp;limit=5&amp;q=title:jones",
        )
        for url in expected_urls:
            assert url in page, url
コード例 #27
0
ファイル: tests.py プロジェクト: AdamJensen-dk/ckan-drupal
    def setup_class(cls):
        model.repo.rebuild_db()
        CreateTestData.create()
        plugins.load('drupal')
        from ckan.plugins import PluginImplementations
        from ckan.plugins.interfaces import IConfigurer
        for plugin in PluginImplementations(IConfigurer):
            plugin.update_config(config)

        url = config['drupal.db_url'] 
        cls.engine = create_engine(url, echo=True)
        cls.metadata = MetaData(cls.engine)
        cls.node = Table('node',
                          cls.metadata,
                          autoload = True)
        cls.node = Table('node_revisions',
                          cls.metadata,
                          autoload = True)
        cls.package_table = Table('ckan_package',
                                  cls.metadata,
                                  autoload = True)
        cls.extra_table = Table('ckan_package_extra',
                                  cls.metadata,
                                  autoload = True)
        cls.resource_table = Table('ckan_resource',
                                  cls.metadata,
                                  autoload = True)
        cls.engine.execute('delete from ckan_package')
        cls.engine.execute('delete from ckan_resource')
        cls.engine.execute('delete from ckan_package_extra')
        cls.engine.execute('delete from ckan_package_tag')
        cls.engine.execute('delete from node')
        cls.engine.execute('delete from node_revisions')
コード例 #28
0
ファイル: test_tag_vocab.py プロジェクト: 1sha1/ckan
    def setup_class(cls):
        plugins.load('test_tag_vocab_plugin')
        CreateTestData.create(package_type='mock_vocab_tags_plugin')
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.dset = model.Package.get('warandpeace')
        cls.tag1_name = 'vocab-tag-1'
        cls.tag2_name = 'vocab-tag-2'

        # use our custom select class for this test suite
        cls.old_select = paste.fixture.Field.classes['select']
        paste.fixture.Field.classes['select'] = Select

        # create a test vocab
        params = json.dumps({'name': TEST_VOCAB_NAME})
        extra_environ = {'Authorization' : str(cls.sysadmin_user.apikey)}
        cls.extra_environ = {'Authorization' : str(cls.sysadmin_user.apikey)}
        response = cls.app.post('/api/action/vocabulary_create', params=params,
                                extra_environ=extra_environ)
        assert json.loads(response.body)['success']
        vocab_id = json.loads(response.body)['result']['id']

        # add tags to the vocab
        extra_environ = {'Authorization' : str(cls.sysadmin_user.apikey)}
        params = json.dumps({'name': cls.tag1_name, 'vocabulary_id': vocab_id})
        response = cls.app.post('/api/action/tag_create', params=params,
                                 extra_environ=extra_environ)
        assert json.loads(response.body)['success']
        params = json.dumps({'name': cls.tag2_name, 'vocabulary_id': vocab_id})
        response = cls.app.post('/api/action/tag_create', params=params,
                                 extra_environ=extra_environ)
        assert json.loads(response.body)['success']
コード例 #29
0
ファイル: create_test_data.py プロジェクト: jasonzou/ckan
    def command(self):
        from ckan import plugins

        self._load_config()
        self._setup_app()
        plugins.load("synchronous_search")  # so packages get indexed
        if self.args:
            cmd = self.args[0]
        else:
            cmd = "basic"
        if self.verbose:
            print "Creating %s test data" % cmd
        if cmd == "basic":
            self.create_basic_test_data()
        elif cmd == "user":
            self.create_test_user()
            print "Created user %r with password %r and apikey %r" % ("tester", "tester", "tester")
        elif cmd == "search":
            self.create_search_test_data()
        elif cmd == "gov":
            self.create_gov_test_data()
        elif cmd == "family":
            self.create_family_test_data()
        else:
            print "Command %s not recognized" % cmd
            raise NotImplementedError
        if self.verbose:
            print "Creating %s test data: Complete!" % cmd
コード例 #30
0
ファイル: cli.py プロジェクト: AltisCorp/ckan
    def command(self):
        self._load_config()
        self._setup_app()
        from ckan import plugins
        plugins.load('synchronous_search') # so packages get indexed
        from create_test_data import CreateTestData

        if self.args:
            cmd = self.args[0]
        else:
            cmd = 'basic'
        if self.verbose:
            print 'Creating %s test data' % cmd
        if cmd == 'basic':
            CreateTestData.create_basic_test_data()
        elif cmd == 'user':
            CreateTestData.create_test_user()
            print 'Created user %r with password %r and apikey %r' % ('tester',
                    'tester', 'tester')
        elif cmd == 'search':
            CreateTestData.create_search_test_data()
        elif cmd == 'gov':
            CreateTestData.create_gov_test_data()
        elif cmd == 'family':
            CreateTestData.create_family_test_data()
        elif cmd == 'translations':
            CreateTestData.create_translations_test_data()
        elif cmd == 'vocabs':
            CreateTestData.create_vocabs_test_data()
        else:
            print 'Command %s not recognized' % cmd
            raise NotImplementedError
        if self.verbose:
            print 'Creating %s test data: Complete!' % cmd
コード例 #31
0
ファイル: test_plugin.py プロジェクト: bwica/origin
    def test_loading_datastore_last_doesnt_work(self):
        # This test is complicated because we can't import
        # ckanext.datastore.plugin before running it. If we did so, the
        # DatastorePlugin class would be parsed which breaks the reason of our
        # test.
        p.load('sample_datastore_plugin')
        thrown_exception = None
        try:
            p.load('datastore')
        except Exception as e:
            thrown_exception = e
        idatastores = [x.__class__.__name__ for x
                       in p.PluginImplementations(interfaces.IDatastore)]
        p.unload('sample_datastore_plugin')

        assert thrown_exception is not None, \
            ('Loading "datastore" after another IDatastore plugin was'
             'loaded should raise DatastoreException')
        assert_equal(thrown_exception.__class__.__name__,
                     plugin.DatastoreException.__name__)
        assert plugin.DatastorePlugin.__name__ not in idatastores, \
            ('You shouldn\'t be able to load the "datastore" plugin after'
             'another IDatastore plugin was loaded')
コード例 #32
0
ファイル: test_middleware.py プロジェクト: xiaohunlt/ckan
    def test_user_objects_in_c_sysadmin(self):
        '''
        A sysadmin user request will have expected user objects added to
        request.
        '''
        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()
        user = factories.Sysadmin()
        test_user_obj = model.User.by_name(user['name'])

        resp = app.get(
            '/from_pylons_extension_before_map',
            extra_environ={'REMOTE_USER': user['name'].encode('ascii')})

        # tmpl_context available on response
        eq_(resp.tmpl_context.user, user['name'])
        eq_(resp.tmpl_context.userobj, test_user_obj)
        eq_(resp.tmpl_context.author, user['name'])
        eq_(resp.tmpl_context.remote_addr, 'Unknown IP Address')

        p.unload('test_routing_plugin')
コード例 #33
0
ファイル: test_middleware.py プロジェクト: xiaohunlt/ckan
    def test_ask_around_flask_core_and_pylons_extension_route(self):

        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()

        # We want our CKAN app, not the WebTest one
        app = app.app

        environ = {
            'PATH_INFO': '/pylons_and_flask',
            'REQUEST_METHOD': 'GET',
        }
        wsgiref.util.setup_testing_defaults(environ)

        answers = app.ask_around(environ)
        answers = sorted(answers, key=lambda a: a[1])

        eq_(answers, [(True, 'flask_app', 'core'),
                      (True, 'pylons_app', 'extension')])

        p.unload('test_routing_plugin')
コード例 #34
0
ファイル: test_middleware.py プロジェクト: xiaohunlt/ckan
    def test_ask_around_pylons_extension_route_post_using_get(self):

        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()

        # We want our CKAN app, not the WebTest one
        app = app.app

        environ = {
            'PATH_INFO': '/from_pylons_extension_before_map_post_only',
            'REQUEST_METHOD': 'GET',
        }
        wsgiref.util.setup_testing_defaults(environ)

        answers = app.ask_around(environ)

        # We are going to get an answer from Pylons, but just because it will
        # match the catch-all template route, hence the `core` origin.
        eq_(answers, [(False, 'flask_app'), (True, 'pylons_app', 'core')])

        p.unload('test_routing_plugin')
コード例 #35
0
ファイル: test_package.py プロジェクト: petrushev/ckan
    def test_register_post_indexerror(self):
        """
        Test that we can't add a package if Solr is down.
        """
        bad_solr_url = 'http://127.0.0.1/badsolrurl'
        original_settings = SolrSettings.get()[0]
        try:
            SolrSettings.init(bad_solr_url)
            plugins.load('synchronous_search')

            assert not self.get_package_by_name(
                self.package_fixture_data['name'])
            offset = self.package_offset()
            data = self.dumps(self.package_fixture_data)

            self.post_json(offset,
                           data,
                           status=500,
                           extra_environ=self.extra_environ)
            model.Session.remove()
        finally:
            plugins.unload('synchronous_search')
            SolrSettings.init(original_settings)
コード例 #36
0
ファイル: test_api.py プロジェクト: Quoin/ckan
    def test_api_info(self):

        dataset = factories.Dataset()
        resource = factories.Resource(
            id='588dfa82-760c-45a2-b78a-e3bc314a4a9b',
            package_id=dataset['id'],
            datastore_active=True)

        # the 'API info' is seen on the resource_read page, a snippet loaded by
        # javascript via data_api_button.html
        url = template_helpers.url_for(controller='api',
                                       action='snippet',
                                       ver=1,
                                       snippet_path='api_info.html',
                                       resource_id=resource['id'])

        if not p.plugin_loaded('datastore'):
            p.load('datastore')

        app = self._get_test_app()
        page = app.get(url, status=200)
        p.unload('datastore')

        # check we built all the urls ok
        expected_urls = (
            'http://test.ckan.net/api/3/action/datastore_create',
            'http://test.ckan.net/api/3/action/datastore_upsert',
            '<code>http://test.ckan.net/api/3/action/datastore_search',
            'http://test.ckan.net/api/3/action/datastore_search_sql',
            'http://test.ckan.net/api/3/action/datastore_search?resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b&amp;limit=5',
            'http://test.ckan.net/api/3/action/datastore_search?q=jones&amp;resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b',
            'http://test.ckan.net/api/3/action/datastore_search_sql?sql=SELECT * from &#34;588dfa82-760c-45a2-b78a-e3bc314a4a9b&#34; WHERE title LIKE &#39;jones&#39;',
            "url: 'http://test.ckan.net/api/3/action/datastore_search'",
            "http://test.ckan.net/api/3/action/datastore_search?resource_id=588dfa82-760c-45a2-b78a-e3bc314a4a9b&amp;limit=5&amp;q=title:jones",
        )
        for url in expected_urls:
            assert url in page, url
コード例 #37
0
ファイル: test_search.py プロジェクト: OpenDataNode/odn-ckan
 def setup_class(cls):
     if not tests.is_datastore_supported():
         raise nose.SkipTest("Datastore not supported")
     p.load('datastore')
     ctd.CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
     cls.normal_user = model.User.get('annafan')
     resource = model.Package.get('annakarenina').resources[0]
     cls.data = dict(
         resource_id=resource.id,
         force=True,
         fields=[
           {'id': 'id'},
           {'id': 'date', 'type':'date'},
           {'id': 'x'},
           {'id': 'y'},
           {'id': 'z'},
           {'id': 'country'},
           {'id': 'title'},
           {'id': 'lat'},
           {'id': 'lon'}
         ],
         records=[
           {'id': 0, 'date': '2011-01-01', 'x': 1, 'y': 2, 'z': 3, 'country': 'DE', 'title': 'first 99', 'lat':52.56, 'lon':13.40},
           {'id': 1, 'date': '2011-02-02', 'x': 2, 'y': 4, 'z': 24, 'country': 'UK', 'title': 'second', 'lat':54.97, 'lon':-1.60},
           {'id': 2, 'date': '2011-03-03', 'x': 3, 'y': 6, 'z': 9, 'country': 'US', 'title': 'third', 'lat':40.00, 'lon':-75.5},
           {'id': 3, 'date': '2011-04-04', 'x': 4, 'y': 8, 'z': 6, 'country': 'UK', 'title': 'fourth', 'lat':57.27, 'lon':-6.20},
           {'id': 4, 'date': '2011-05-04', 'x': 5, 'y': 10, 'z': 15, 'country': 'UK', 'title': 'fifth', 'lat':51.58, 'lon':0},
           {'id': 5, 'date': '2011-06-02', 'x': 6, 'y': 12, 'z': 18, 'country': 'DE', 'title': 'sixth 53.56', 'lat':51.04, 'lon':7.9}
         ]
     )
     postparams = '%s=1' % json.dumps(cls.data)
     auth = {'Authorization': str(cls.normal_user.apikey)}
     res = cls.app.post('/api/action/datastore_create', params=postparams,
                        extra_environ=auth)
     res_dict = json.loads(res.body)
     assert res_dict['success'] is True
コード例 #38
0
    def setup_class(cls):
        p.load('timeseries')
        helpers.reset_db()
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        engine = db._get_engine(
            {'connection_url': pylons.config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
        cls.dataset = model.Package.get('annakarenina')

        cls.data = {
            'resource_id':
            '',
            'force':
            True,
            'method':
            'insert',
            'records': [{
                'author': 'tolstoy5',
                'published': '2005-03-05'
            }, {
                'author': 'tolstoy6'
            }, {
                'author': 'tolstoy7',
                'published': '2005-03-05'
            }]
        }

        cls.data['resource_id'] = cls.dataset.resources[0].id
        result = helpers.call_action('datastore_ts_create', **cls.data)

        cls.data['resource_id'] = cls.dataset.resources[1].id
        result = helpers.call_action('datastore_ts_create', **cls.data)

        datastore_test_helpers.set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
コード例 #39
0
ファイル: test_delete.py プロジェクト: whsheng/ckan
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id':
            resource.id,
            'aliases':
            u'b\xfck2',
            'fields': [{
                'id': 'book',
                'type': 'text'
            }, {
                'id': 'author',
                'type': 'text'
            }, {
                'id': 'rating with %',
                'type': 'text'
            }],
            'records': [{
                'book': 'annakarenina',
                'author': 'tolstoy',
                'rating with %': '90%'
            }, {
                'book': 'warandpeace',
                'author': 'tolstoy',
                'rating with %': '42%'
            }]
        }

        engine = db._get_engine(
            {'connection_url': pylons.config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #40
0
ファイル: test_dump.py プロジェクト: changhw01/OpenFoodData
    def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'force': True,
            'aliases': 'books',
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'published'},
                       {'id': u'characters', u'type': u'_text'}],
            'records': [{u'b\xfck': 'annakarenina',
                        'author': 'tolstoy',
                        'published': '2005-03-01',
                        'nested': ['b', {'moo': 'moo'}],
                        u'characters': [u'Princess Anna', u'Sergius']},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                         'nested': {'a': 'b'}}]
        }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine({
            'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #41
0
    def test_ask_around_pylons_extension_route_get_after_map(self):

        if not p.plugin_loaded('test_routing_plugin'):
            p.load('test_routing_plugin')

        app = self._get_test_app()

        # We want our CKAN app, not the WebTest one
        app = app.app

        environ = {
            'PATH_INFO': '/from_pylons_extension_after_map',
            'REQUEST_METHOD': 'GET',
        }
        wsgiref.util.setup_testing_defaults(environ)

        answers = app.ask_around('can_handle_request', environ)

        eq_(len(answers), 1)
        eq_(answers[0][0], True)
        eq_(answers[0][1], 'pylons_app')
        eq_(answers[0][2], 'extension')

        p.unload('test_routing_plugin')
コード例 #42
0
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('timeseries')
        helpers.reset_db()

        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'nested', 'type': 'json'},
                       {'id': 'characters', 'type': 'text[]'},
                       {'id': 'published'}],
            'primary_key': u'b\xfck',
            'records': [{u'b\xfck': 'annakarenina', 'author': 'tolstoy',
                        'published': '2005-03-01', 'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                        'nested': {'a':'b'}}
                       ]
            }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_ts_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine(
            {'connection_url': pylons.config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #43
0
ファイル: test_delete.py プロジェクト: usuariobkp/ckan
    def setup_class(cls):
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'aliases': 'books2',
            'fields': [{'id': 'book', 'type': 'text'},
                       {'id': 'author', 'type': 'text'}],
            'records': [{'book': 'annakarenina', 'author': 'tolstoy'},
                        {'book': 'warandpeace', 'author': 'tolstoy'}]
        }

        #model.repo.rebuild_db()
        #model.repo.clean_db()

        import pylons
        engine = db._get_engine(
                None,
                {'connection_url': pylons.config['ckan.datastore.write_url']}
            )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #44
0
    def command(self):
        self._load_config()
        self._setup_app()

        # Now we can import
        from ckan import plugins
        from ckanext.dgu.testtools.create_test_data import DguCreateTestData

        plugins.load('synchronous_search')  # so packages get indexed
        self.log = logging.getLogger(__name__)

        if self.args:
            cmd = self.args[0]
        else:
            cmd = 'basic'
        if cmd == 'basic':
            DguCreateTestData.create_dgu_test_data()
        elif cmd == 'users':
            DguCreateTestData.create_dgu_test_users()
        else:
            print 'Command %s not recognized' % cmd
            raise NotImplementedError

        self.log.info('Created DGU test data successfully')
コード例 #45
0
    def setup_class(self, **kwargs):
        # Every time the test is run, the database is resetted
        reset_db()

        if not plugins.plugin_loaded('image_view'):
            plugins.load('image_view')

        if not plugins.plugin_loaded('orgportals'):
            plugins.load('orgportals')

        organization_name = id_generator()
        dataset_name = id_generator()
        group_name = id_generator()
        resource_name = id_generator()
        resource_view_title = id_generator()

        self.mock_data = create_mock_data(
            organization_name=organization_name,
            dataset_name=dataset_name,
            group_name=group_name,
            resource_name=resource_name,
            resource_view_title=resource_view_title)

        self.subdashboard = create_subdashboard(self.mock_data)
コード例 #46
0
 def setup_class(cls):
     p.load('datastore')
     ctd.CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
     cls.normal_user = model.User.get('annafan')
     resource = model.Package.get('annakarenina').resources[0]
     cls.data = {
         'resource_id':
         resource.id,
         'fields': [{
             'id': 'book',
             'type': 'text'
         }, {
             'id': 'author',
             'type': 'text'
         }],
         'records': [{
             'book': 'annakarenina',
             'author': 'tolstoy'
         }, {
             'book': 'warandpeace',
             'author': 'tolstoy'
         }]
     }
コード例 #47
0
    def setup_class(cls):
        if not is_datastore_supported():
            raise nose.SkipTest('Datastore not supported')
        if not p.plugin_loaded('datastore'):
            p.load('datastore')
        if not p.plugin_loaded('datapusher'):
            p.load('datapusher')
        if not p.plugin_loaded('recline_grid_view'):
            p.load('recline_grid_view')

        helpers.reset_db()
コード例 #48
0
ファイル: test_search.py プロジェクト: defvol/ckan-1
    def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        plugin = p.load('datastore')
        if plugin.legacy_mode:
            raise nose.SkipTest("SQL tests are not supported in legacy mode")
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'aliases': 'books4',
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'published'}],
            'records': [{u'b\xfck': 'annakarenina',
                        'author': 'tolstoy',
                        'published': '2005-03-01',
                        'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace',
                        'author': 'tolstoy',
                        'nested': {'a':'b'}}
                       ]
        }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        cls.expected_records = [{u'_full_text': u"'annakarenina':1 'b':3 'moo':4 'tolstoy':2",
                                  u'_id': 1,
                                  u'author': u'tolstoy',
                                  u'b\xfck': u'annakarenina',
                                  u'nested': [u'b', {u'moo': u'moo'}],
                                  u'published': u'2005-03-01T00:00:00'},
                                 {u'_full_text': u"'b':3 'tolstoy':2 'warandpeac':1",
                                  u'_id': 2,
                                  u'author': u'tolstoy',
                                  u'b\xfck': u'warandpeace',
                                  u'nested': {u'a': u'b'},
                                  u'published': None}]
        cls.expected_join_results = [{u'first': 1, u'second': 1}, {u'first': 1, u'second': 2}]
コード例 #49
0
    def setup_class(cls):
        cls.app = helpers._get_test_app()

        if not p.plugin_loaded('multilingual_dataset'):
            p.load('multilingual_dataset')

        if not p.plugin_loaded('multilingual_group'):
            p.load('multilingual_group')

        if not p.plugin_loaded('multilingual_tag'):
            p.load('multilingual_tag')

        ckan.tests.legacy.setup_test_search_index()
        _create_test_data.CreateTestData.create_translations_test_data()

        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.org = {
            'name': 'test_org',
            'title': 'russian',
            'description': 'Roger likes these books.'
        }
        ckan.tests.legacy.call_action_api(cls.app,
                                          'organization_create',
                                          apikey=cls.sysadmin_user.apikey,
                                          **cls.org)
        dataset = {
            'name': 'test_org_dataset',
            'title': 'A Novel By Tolstoy',
            'owner_org': cls.org['name']
        }
        ckan.tests.legacy.call_action_api(cls.app,
                                          'package_create',
                                          apikey=cls.sysadmin_user.apikey,
                                          **dataset)

        # Add translation terms that match a couple of group names and package
        # names. Group names and package names should _not_ get translated even
        # if there are terms matching them, because they are used to form URLs.
        for term in ('roger', 'david', 'annakarenina', 'warandpeace'):
            for lang_code in ('en', 'de', 'fr'):
                data_dict = {
                    'term': term,
                    'term_translation': 'this should not be rendered',
                    'lang_code': lang_code
                }
                context = {
                    'model': ckan.model,
                    'session': ckan.model.Session,
                    'user': '******'
                }
                ckan.logic.action.update.term_translation_update(
                    context, data_dict)
コード例 #50
0
    def setup(self):
        test_helpers.reset_db()
        init_tables_ga()
        setup_user_authority_table()
        setup_user_authority_dataset_table()
        setup_featured_charts_table()
        setup_most_active_organizations_table()

        rebuild()

        if not plugins.plugin_loaded('c3charts'):
            plugins.load('c3charts')

        if not plugins.plugin_loaded('datagovmk'):
            plugins.load('datagovmk')

        if not plugins.plugin_loaded('scheming_organizations'):
            plugins.load('scheming_organizations')

        if not plugins.plugin_loaded('fluent'):
            plugins.load('fluent')
コード例 #51
0
    def setup_class(cls):
        cls.app = _get_test_app()
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        p.load('datapusher')
        p.load('test_datapusher_plugin')

        resource = factories.Resource(url_type='datastore')
        cls.dataset = factories.Dataset(resources=[resource])

        cls.sysadmin_user = factories.User(name='testsysadmin', sysadmin=True)
        cls.normal_user = factories.User(name='annafan')
        engine = db.get_write_engine()
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #52
0
ファイル: test_interfaces.py プロジェクト: rahul-nath/ckan
    def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        p.load('datapusher')
        p.load('test_datapusher_plugin')

        resource = factories.Resource(url_type='datastore')
        cls.dataset = factories.Dataset(resources=[resource])

        cls.sysadmin_user = factories.User(name='testsysadmin', sysadmin=True)
        cls.normal_user = factories.User(name='annafan')
        engine = db.get_write_engine()
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
コード例 #53
0
ファイル: test_create.py プロジェクト: zhubx007/ckan
 def setup_class(cls):
     if not p.plugin_loaded('image_view'):
         p.load('image_view')
コード例 #54
0
    def setup_class(cls):
        if not p.plugin_loaded('image_view'):
            p.load('image_view')

        helpers.reset_db()
コード例 #55
0
ファイル: test_plugins.py プロジェクト: sirca/ckan
 def setup(cls):
     cls.observer = plugins.load('test_observer_plugin')
コード例 #56
0
ファイル: test_plugins.py プロジェクト: sirca/ckan
 def test_inexistent_plugin_loading(self):
     plugins.load('inexistent-plugin')
コード例 #57
0
 def __init__(self):
     from ckan import plugins
     if not is_search_supported():
         raise SkipTest("Search not supported")
     plugins.load('synchronous_search')
コード例 #58
0
 def setup_class(cls):
     p.load('datastore')
コード例 #59
0
 def test_loading_datastore_first_works(self):
     p.load('datastore')
     p.load('sample_datastore_plugin')
     p.unload('sample_datastore_plugin')
     p.unload('datastore')
コード例 #60
0
 def setup_class(cls):
     cls.original_config = config.copy()
     plugins.load('example_idatasetform_v4')