Exemplo n.º 1
0
    def setup_class(cls):
        if not tests.is_search_supported():
            raise tests.SkipTest("Search not supported")
        tests.setup_test_search_index()

        ctd.CreateTestData.create()

        model.repo.new_revision()
        cls.vocab = model.Vocabulary(TEST_VOCAB_NAME)
        model.Session.add(cls.vocab)
        model.Session.commit()

        vocab_tag_1 = model.Tag('tag1', cls.vocab.id)
        vocab_tag_2 = model.Tag('tag2', cls.vocab.id)
        model.Session.add(vocab_tag_1)
        model.Session.add(vocab_tag_2)

        pkg = model.Package.get('warandpeace')
        pkg_tag1 = model.PackageTag(pkg, vocab_tag_1)
        pkg_tag2 = model.PackageTag(pkg, vocab_tag_2)
        model.Session.add(pkg_tag1)
        model.Session.add(pkg_tag2)

        model.Session.commit()
        model.Session.remove()
Exemplo n.º 2
0
    def setup_class(self):
        try:
            search.clear()
            setup_test_search_index()
            super(OnsLoaderBase, self).setup_class()

            # make annafan a sysadmin to allow package creation
            rev = model.repo.new_revision()
            user = model.User.by_name(u'annafan')
            model.add_user_to_role(user, model.Role.ADMIN, model.System())
            model.repo.commit_and_remove()

            publist = [g.name for g in model.Session.query(model.Group).all()]

            # create test publishers
            rev = model.repo.new_revision()
            for name, title in publishers.items():
                if not name in publist:
                    model.Session.add(model.Group(name=unicode(name), title=title, type='publisher'))
            model.repo.commit_and_remove()
        except Exception, e:
            # ensure that mock_drupal is destroyed
            print e
            MockDrupalCase.teardown_class()
            #model.repo.rebuild_db()
            raise
Exemplo n.º 3
0
    def setup_class(cls):
        setup_test_search_index()
        model.repo.init_db()

        # no. entities per page is hardcoded into the controllers, so
        # create enough of each here so that we can test pagination
        cls.num_groups = 21
        cls.num_packages_in_large_group = 51
        cls.num_users = 21

        groups = [
            u'group_%s' % str(i).zfill(2) for i in range(1, cls.num_groups)
        ]
        users = [u'user_%s' % str(i).zfill(2) for i in range(cls.num_users)]
        packages = []
        for i in range(cls.num_packages_in_large_group):
            packages.append({
                'name': u'package_%s' % str(i).zfill(2),
                'groups': u'group_00'
            })

        CreateTestData.create_arbitrary(
            packages,
            extra_group_names=groups,
            extra_user_names=users,
        )
Exemplo n.º 4
0
 def setup_class(self):
     setup_test_search_index()
     CreateTestData.create()
     self.package_fixture_data = {
         'name':
         u'testpkg',
         'title':
         'Some Title',
         'url':
         u'http://blahblahblah.mydomain',
         'resources': [{
             u'url': u'http://blahblahblah.mydomain',
             u'format': u'',
             u'description': ''
         }],
         'tags': ['russion', 'novel'],
         'license_id':
         u'gpl-3.0',
         'extras': {
             'national_statistic': 'yes',
             'geographic_coverage': 'England, Wales'
         },
     }
     CreateTestData.create_arbitrary(self.package_fixture_data)
     self.base_url = self.offset('/search/dataset')
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'a',
             'extras': {
                 'department': 'abc',
                 'agency': 'ag-a'
             },
         },
         {
             'name': 'b',
             'extras': {
                 'department': 'bcd',
                 'agency': 'ag-b'
             },
         },
         {
             'name': 'c',
             'extras': {
                 'department': 'cde abc'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'department': ''
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
Exemplo n.º 6
0
    def setup_class(self):
        try:
            search.clear()
            setup_test_search_index()
            super(OnsLoaderBase, self).setup_class()

            # make annafan a sysadmin to allow package creation
            rev = model.repo.new_revision()
            user = model.User.by_name(u'annafan')
            model.add_user_to_role(user, model.Role.ADMIN, model.System())
            model.repo.commit_and_remove()

            publist = [g.name for g in model.Session.query(model.Group).all()]

            # create test publishers
            rev = model.repo.new_revision()
            for name, title in publishers.items():
                if not name in publist:
                    model.Session.add(model.Group(name=unicode(name), title=title, type='publisher'))
            model.repo.commit_and_remove()
        except Exception, e:
            # ensure that mock_drupal is destroyed
            print e
            MockDrupalCase.teardown_class()
            #model.repo.rebuild_db()
            raise
Exemplo n.º 7
0
    def setup_class(cls):
        setup_test_search_index()
        # Force a garbage collection to trigger issue #695
        import gc
        gc.collect()

        CreateTestData.create()

        cls.new_pkg_dict = {
            'name':
            'council-owned-litter-bins',
            'notes':
            'Location of Council owned litter bins within Borough.',
            'resources': [{
                'description': 'Resource locator',
                'format': 'Unverified',
                'url': 'http://www.barrowbc.gov.uk'
            }],
            'tags': ['Utility and governmental services'],
            'title':
            'Council Owned Litter Bins',
            'extras': {
                'INSPIRE':
                'True',
                'bbox-east-long':
                '-3.12442',
                'bbox-north-lat':
                '54.218407',
                'bbox-south-lat':
                '54.039634',
                'bbox-west-long':
                '-3.32485',
                'constraint':
                'conditions unknown; (e) intellectual property rights;',
                'dataset-reference-date': [{
                    'type': 'creation',
                    'value': '2008-10-10'
                }, {
                    'type': 'revision',
                    'value': '2009-10-08'
                }],
                'guid':
                '00a743bf-cca4-4c19-a8e5-e64f7edbcadd',
                'metadata-date':
                '2009-10-16',
                'metadata-language':
                'eng',
                'published_by':
                0,
                'resource-type':
                'dataset',
                'spatial-reference-system':
                'test-spatial',
                'temporal_coverage-from':
                '1977-03-10T11:45:30',
                'temporal_coverage-to':
                '2005-01-15T09:10:00'
            }
        }
Exemplo n.º 8
0
    def setup_class(cls):
        setup_test_search_index()
        assert_solr_schema_is_the_dgu_variant()

        CreateTestData.create_user('sysadmin')
        model.add_user_to_role(model.User.by_name(u'sysadmin'),
                               model.Role.ADMIN, model.System())
        model.repo.commit_and_remove()
    def setup_class(cls):
        setup_test_search_index()
        assert_solr_schema_is_the_dgu_variant()

        CreateTestData.create_user('sysadmin')
        model.add_user_to_role(model.User.by_name(u'sysadmin'),
                               model.Role.ADMIN, model.System())
        model.repo.commit_and_remove()
Exemplo n.º 10
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {"name": "a", "extras": {"department": "abc", "agency": "ag-a"}},
         {"name": "b", "extras": {"department": "bcd", "agency": "ag-b"}},
         {"name": "c", "extras": {"department": "cde abc"}},
         {"name": "none", "extras": {"department": ""}},
     ]
     CreateTestData.create_arbitrary(init_data)
Exemplo n.º 11
0
 def setup_class(self):
     setup_test_search_index()
     model.Session.remove()
     CreateTestData.create()
     self.groupname = u'david'
     self.packagename = u'testpkg'
     model.repo.new_revision()
     model.Session.add(model.Package(name=self.packagename))
     model.repo.commit_and_remove()
Exemplo n.º 12
0
 def setup_class(self):
     setup_test_search_index()
     model.Session.remove()
     CreateTestData.create()
     self.groupname = u'david'
     self.packagename = u'testpkg'
     model.repo.new_revision()
     model.Session.add(model.Package(name=self.packagename))
     model.repo.commit_and_remove()
Exemplo n.º 13
0
 def setup_class(self):
     super(TestSpatialApi,self).setup_class()
     setup_test_search_index()
     CreateTestData.create_test_user()
     self.package_fixture_data = {
         'name' : u'test-spatial-dataset-search-point',
         'title': 'Some Title',
         'extras': [{'key':'spatial','value':self.geojson_examples['point']}]
     }
     self.base_url = self.offset('/search/dataset/geo')
Exemplo n.º 14
0
 def setup_class(cls):
     model.Session.remove()
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     # now remove a tag so we can test search with deleted tags
     model.repo.new_revision()
     gils = model.Package.by_name(u'gils')
     # an existing tag used only by gils
     cls.tagname = u'registry'
     idx = [t.name for t in gils.get_tags()].index(cls.tagname)
     gils.remove_tag(gils.get_tags()[idx])
     model.repo.commit_and_remove()
 def setup_class(cls):
     model.Session.remove()
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     # now remove a tag so we can test search with deleted tags
     model.repo.new_revision()
     gils = model.Package.by_name(u'gils')
     # an existing tag used only by gils
     cls.tagname = u'registry'
     idx = [t.name for t in gils.get_tags()].index(cls.tagname)
     gils.remove_tag(gils.get_tags()[idx])
     model.repo.commit_and_remove()
Exemplo n.º 16
0
 def setup_class(self):
     super(TestSpatialApi, self).setup_class()
     setup_test_search_index()
     CreateTestData.create_test_user()
     self.package_fixture_data = {
         'name': u'test-spatial-dataset-search-point',
         'title': 'Some Title',
         'extras': [{
             'key': 'spatial',
             'value': self.geojson_examples['point']
         }]
     }
     self.base_url = self.offset('/search/dataset/geo')
Exemplo n.º 17
0
    def setup_class(cls):
        model.Session.remove()
        tests.setup_test_search_index()

        _create_test_data.create_arbitrary(data.ecportal_search_items)
        _create_test_data.create('publisher')

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

        for plugin in ['ecportal', 'ecportal_form', 'ecportal_publisher_form',
                       'ecportal_controller']:
            plugins.load(plugin)
Exemplo n.º 18
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {"name": "eng", "extras": {"geographic_coverage": "100000: England"}},
         {"name": "eng_ni", "extras": {"geographic_coverage": "100100: England, Northern Ireland"}},
         {
             "name": "uk",
             "extras": {"geographic_coverage": "111100: United Kingdom (England, Scotland, Wales, Northern Ireland"},
         },
         {"name": "gb", "extras": {"geographic_coverage": "111000: Great Britain (England, Scotland, Wales)"}},
         {"name": "none", "extras": {"geographic_coverage": "000000:"}},
     ]
     CreateTestData.create_arbitrary(init_data)
Exemplo n.º 19
0
 def setup_class(cls):
     model.repo.new_revision()
     tests.setup_test_search_index()
     CreateTestData.create_arbitrary(test_data)
     CreateTestData.create_groups([{
         'name': 'publisher1',
         'packages': ['boolean1', 'boolean2', 'boolean3']
     }])
     model.Session.commit()
     for plugin in ['ecportal',
                    'ecportal_form',
                    'ecportal_publisher_form',
                    'ecportal_controller']:
         plugins.load(plugin)
Exemplo n.º 20
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [{'name':u'test1-penguin-canary',
                   'title':u'penguin',
                   'tags':u'canary goose squirrel wombat wombat'.split()},
                  {'name':u'test2-squirrel-squirrel-canary-goose',
                   'title':u'squirrel goose',
                   'tags':u'penguin wombat'.split()},
                  ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary',
         u'test2-squirrel-squirrel-canary-goose'
     ]
Exemplo n.º 21
0
    def setup_class(self):
        super(TestActionPackageSearch,self).setup_class()
        setup_test_search_index()
        self.package_fixture_data_1 = {
            'name' : u'test-spatial-dataset-search-point-1',
            'title': 'Some Title 1',
            'extras': [{'key':'spatial','value':self.geojson_examples['point']}]
        }
        self.package_fixture_data_2 = {
            'name' : u'test-spatial-dataset-search-point-2',
            'title': 'Some Title 2',
            'extras': [{'key':'spatial','value':self.geojson_examples['point_2']}]
        }

        CreateTestData.create()
Exemplo n.º 22
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'eng',
          'extras':{'geographic_coverage':'100000: England'},},
         {'name':'eng_ni',
          'extras':{'geographic_coverage':'100100: England, Northern Ireland'},},
         {'name':'uk',
          'extras':{'geographic_coverage':'111100: United Kingdom (England, Scotland, Wales, Northern Ireland'},},
         {'name':'gb',
          'extras':{'geographic_coverage':'111000: Great Britain (England, Scotland, Wales)'},},
         {'name':'none',
          'extras':{'geographic_coverage':'000000:'},},
     ]
     CreateTestData.create_arbitrary(init_data)
Exemplo n.º 23
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {'name':'a',
          'extras':{'department':'abc',
                    'agency':'ag-a'},},
         {'name':'b',
          'extras':{'department':'bcd',
                    'agency':'ag-b'},},
         {'name':'c',
          'extras':{'department':'cde abc'},},
         {'name':'none',
          'extras':{'department':''},},
         ]
     CreateTestData.create_arbitrary(init_data)
Exemplo n.º 24
0
 def setup_class(self):
     setup_test_search_index()
     CreateTestData.create()
     self.package_fixture_data = {
         'name' : u'testpkg',
         'title': 'Some Title',
         'url': u'http://blahblahblah.mydomain',
         'resources': [{u'url':u'http://blahblahblah.mydomain',
                        u'format':u'', u'description':''}],
         'tags': ['russion', 'novel'],
         'license_id': u'gpl-3.0',
         'extras': {'national_statistic':'yes',
                    'geographic_coverage':'England, Wales'},
     }
     CreateTestData.create_arbitrary(self.package_fixture_data)
     self.base_url = self.offset('/search/dataset')
Exemplo n.º 25
0
    def setup_class(cls):
        setup_test_search_index()
        model.repo.init_db()

        # no. entities per page is hardcoded into the controllers, so
        # create enough of each here so that we can test pagination
        cls.num_packages_in_large_group = 51

        packages = []
        for i in range(cls.num_packages_in_large_group):
            packages.append({
                'name': u'dataset_%s' % str(i).zfill(2),
                'groups': u'group_00'
            })

        CreateTestData.create_arbitrary(packages)
Exemplo n.º 26
0
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             "name": u"test1-penguin-canary",
             "title": u"penguin",
             "tags": u"canary goose squirrel wombat wombat".split(),
         },
         {
             "name": u"test2-squirrel-squirrel-canary-goose",
             "title": u"squirrel goose",
             "tags": u"penguin wombat".split(),
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [u"test1-penguin-canary", u"test2-squirrel-squirrel-canary-goose"]
Exemplo n.º 27
0
    def setup_class(self):
        search.clear()
        setup_test_search_index()
        super(OnsLoaderBase, self).setup_class()

        # make annafan a sysadmin to allow package creation
        rev = model.repo.new_revision()
        user = model.User.by_name(u'annafan')
        model.add_user_to_role(user, model.Role.ADMIN, model.System())
        model.repo.commit_and_remove()

        # create test publishers
        rev = model.repo.new_revision()
        for name, title in publishers.items():
            model.Session.add(model.Group(name=unicode(name), title=title, type='publisher'))
        model.repo.commit_and_remove()
Exemplo n.º 28
0
    def setup_class(cls):
        model.Session.remove()
        tests.setup_test_search_index()

        _create_test_data.create_arbitrary(data.ecportal_search_items)
        _create_test_data.create('publisher')

        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.sysadmin_env = {'Authorization': str(cls.sysadmin_user.apikey)}

        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)

        mu = model.Member(table_id=usr.id, table_name='user', group=g)
        model.Session.add(mu)
        model.Session.commit()

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

        # create geographical coverage vocab
        cls.geo_tags = [(u'uk', u'United Kingdom'), (u'ie', u'Ireland')]
        geo = test_api.create_vocab(u'geographical_coverage',
                                    cls.sysadmin_user.name)
        cls.geo_vocab_id = geo['id']

        for tag in cls.geo_tags:
            test_api.add_tag_to_vocab(tag[0], cls.geo_vocab_id,
                                      cls.sysadmin_user.name)
            params = json.dumps({
                'term': tag[0],
                'term_translation': tag[1],
                'lang_code': u'en'
            })
            response = cls.app.post('/api/action/term_translation_update',
                                    params=params,
                                    extra_environ=cls.sysadmin_env)
            assert json.loads(response.body)['success']
Exemplo n.º 29
0
    def setup_class(self):
        search.clear()
        setup_test_search_index()
        super(OnsLoaderBase, self).setup_class()

        # make annafan a sysadmin to allow package creation
        rev = model.repo.new_revision()
        user = model.User.by_name(u'annafan')
        model.add_user_to_role(user, model.Role.ADMIN, model.System())
        model.repo.commit_and_remove()

        # create test publishers
        rev = model.repo.new_revision()
        for name, title in publishers.items():
            model.Session.add(
                model.Group(name=unicode(name), title=title, type='publisher'))
        model.repo.commit_and_remove()
Exemplo n.º 30
0
 def test_read(self):
     # Relies on the search index being available
     setup_test_search_index()
     name = u'david'
     title = u'Dave\'s books'
     pkgname = u'warandpeace'
     group = model.Group.by_name(name)
     assert 'publisher' == group.type
     for group_ref in (group.name, group.id):
         offset = url_for(controller='group', action='read', id=group_ref)
         res = self.app.get(offset)
         main_res = self.main_div(res)
         assert title in res, res
         assert 'Administrators' in res, res
         assert 'russianfan' in main_res, main_res
         assert name in res, res
         assert '0 datasets found.' in self.strip_tags(main_res), main_res
Exemplo n.º 31
0
 def test_read(self):
     # Relies on the search index being available
     setup_test_search_index()
     name = u'david'
     title = u'Dave\'s books'
     pkgname = u'warandpeace'
     group = model.Group.by_name(name)
     assert 'publisher' == group.type
     for group_ref in (group.name, group.id):
         offset = url_for(controller='group', action='read', id=group_ref)
         res = self.app.get(offset)
         main_res = self.main_div(res)
         assert title in res, res
         assert 'Administrators' in res, res
         assert 'russianfan' in main_res, main_res
         assert name in res, res
         assert '0 datasets found.' in self.strip_tags(main_res), main_res
Exemplo n.º 32
0
    def setup_class(cls):
        setup_test_search_index()
        model.repo.init_db()

        # no. entities per page is hardcoded into the controllers, so
        # create enough of each here so that we can test pagination
        cls.num_packages_in_large_group = 51

        packages = []
        for i in range(cls.num_packages_in_large_group):
            packages.append({
                # CS: nasty_string ignore
                'name': u'dataset_%s' % str(i).zfill(2),
                'groups': u'group_00'
            })

        CreateTestData.create_arbitrary(packages)
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': u'test1-penguin-canary',
             'title': u'penguin',
             'tags': u'canary goose squirrel wombat wombat'.split()
         },
         {
             'name': u'test2-squirrel-squirrel-canary-goose',
             'title': u'squirrel goose',
             'tags': u'penguin wombat'.split()
         },
     ]
     CreateTestData.create_arbitrary(init_data)
     cls.pkg_names = [
         u'test1-penguin-canary', u'test2-squirrel-squirrel-canary-goose'
     ]
Exemplo n.º 34
0
    def setup_class(self):
        model.repo.init_db()
        q = model.Session.query(model.UserObjectRole) \
            .filter(sa.or_(model.UserObjectRole.role==model.Role.EDITOR,
                           model.UserObjectRole.role==model.Role.ANON_EDITOR)) \
            .filter(model.UserObjectRole.user==model.User.by_name(u"visitor"))
        for role in q:
            model.Session.delete(role)

        q = model.Session.query(model.RoleAction).filter(model.RoleAction.role==model.Role.READER)
        for role_action in q:
            model.Session.delete(role_action)

        model.repo.commit_and_remove()
        setup_test_search_index()
        TestUsage._create_test_data()
        model.Session.remove()
        self.user_name = TestUsage.mrloggedin.name.encode('utf-8')
Exemplo n.º 35
0
    def setup_class(self):
        setup_test_search_index()
        CreateTestData.create()
        self.non_active_name = u'test_nonactive'
        pkg = model.Package(name=self.non_active_name)
        model.repo.new_revision()
        model.Session.add(pkg)
        model.repo.commit_and_remove()

        pkg = model.Session.query(model.Package).filter_by(name=self.non_active_name).one()
        admin = model.User.by_name(u'joeadmin')
        model.setup_default_user_roles(pkg, [admin])
        model.repo.commit_and_remove()

        model.repo.new_revision()        
        pkg = model.Session.query(model.Package).filter_by(name=self.non_active_name).one()
        pkg.delete() # becomes non active
        model.repo.commit_and_remove()
Exemplo n.º 36
0
    def setup_class(self):
        setup_test_search_index()
        CreateTestData.create()
        self.non_active_name = u'test_nonactive'
        pkg = model.Package(name=self.non_active_name)
        model.repo.new_revision()
        model.Session.add(pkg)
        model.repo.commit_and_remove()

        pkg = model.Session.query(model.Package).filter_by(name=self.non_active_name).one()
        admin = model.User.by_name(u'joeadmin')
        model.setup_default_user_roles(pkg, [admin])
        model.repo.commit_and_remove()

        model.repo.new_revision()        
        pkg = model.Session.query(model.Package).filter_by(name=self.non_active_name).one()
        pkg.delete() # becomes non active
        model.repo.commit_and_remove()
Exemplo n.º 37
0
    def setup_class(self):
        model.repo.init_db()
        q = model.Session.query(model.UserObjectRole) \
            .filter(sa.or_(model.UserObjectRole.role==model.Role.EDITOR,
                           model.UserObjectRole.role==model.Role.ANON_EDITOR)) \
            .filter(model.UserObjectRole.user==model.User.by_name(u"visitor"))
        for role in q:
            model.Session.delete(role)

        q = model.Session.query(model.RoleAction).filter(
            model.RoleAction.role == model.Role.READER)
        for role_action in q:
            model.Session.delete(role_action)

        model.repo.commit_and_remove()
        setup_test_search_index()
        TestUsage._create_test_data()
        model.Session.remove()
        self.user_name = TestUsage.mrloggedin.name.encode('utf-8')
Exemplo n.º 38
0
    def test_sorting_datasets_by_total_views(self):
        # FIXME: Have some datasets with different numbers of recent and total
        # views, to make this a better test.
        import ckan.lib.search

        tests.setup_test_search_index()

        app = self._get_app()
        sysadmin_user, apikey = self._create_sysadmin(app)
        self._create_package(app, apikey, name='consider_phlebas')
        self._create_package(app, apikey, name='the_player_of_games')
        self._create_package(app, apikey, name='use_of_weapons')

        url = routes.url_for(controller='package',
                             action='read',
                             id='consider_phlebas')
        self._post_to_tracking(app, url)

        url = routes.url_for(controller='package',
                             action='read',
                             id='the_player_of_games')
        self._post_to_tracking(app, url, ip='111.11.111.111')
        self._post_to_tracking(app, url, ip='222.22.222.222')

        url = routes.url_for(controller='package',
                             action='read',
                             id='use_of_weapons')
        self._post_to_tracking(app, url, ip='111.11.111.111')
        self._post_to_tracking(app, url, ip='222.22.222.222')
        self._post_to_tracking(app, url, ip='333.33.333.333')

        self._update_tracking_summary()
        ckan.lib.search.rebuild()

        response = tests.call_action_api(app,
                                         'package_search',
                                         sort='views_total desc')
        assert response['count'] == 3
        assert response['sort'] == 'views_total desc'
        packages = response['results']
        assert packages[0]['name'] == 'use_of_weapons'
        assert packages[1]['name'] == 'the_player_of_games'
        assert packages[2]['name'] == 'consider_phlebas'
Exemplo n.º 39
0
    def test_read(self):
        from pylons import config
        from nose.exc import SkipTest
        if config.get('ckan.auth.profile', '') != 'publisher':
            raise SkipTest('Publisher auth profile not enabled')

        # Relies on the search index being available
        setup_test_search_index()
        name = u'david'
        title = u'Dave\'s books'
        pkgname = u'warandpeace'
        group = model.Group.by_name(name)
        assert 'publisher' == group.type
        for group_ref in (group.name, group.id):
            offset = url_for(controller='group', action='read', id=group_ref)
            res = self.app.get(offset)
            main_res = self.main_div(res)
            assert title in res, res
            assert 'Administrators' in res, res
            assert 'russianfan' in main_res, main_res
            assert name in res, res
            assert '0 datasets found.' in self.strip_tags(main_res), main_res
Exemplo n.º 40
0
    def test_sorting_datasets_by_total_views(self):
        # FIXME: Have some datasets with different numbers of recent and total
        # views, to make this a better test.
        import ckan.lib.search

        tests.setup_test_search_index()

        app = self._get_app()
        sysadmin_user, apikey = self._create_sysadmin(app)
        self._create_package(app, apikey, name='consider_phlebas')
        self._create_package(app, apikey, name='the_player_of_games')
        self._create_package(app, apikey, name='use_of_weapons')

        url = routes.url_for(controller='package', action='read',
                             id='consider_phlebas')
        self._post_to_tracking(app, url)

        url = routes.url_for(controller='package', action='read',
                             id='the_player_of_games')
        self._post_to_tracking(app, url, ip='111.11.111.111')
        self._post_to_tracking(app, url, ip='222.22.222.222')

        url = routes.url_for(controller='package', action='read',
                             id='use_of_weapons')
        self._post_to_tracking(app, url, ip='111.11.111.111')
        self._post_to_tracking(app, url, ip='222.22.222.222')
        self._post_to_tracking(app, url, ip='333.33.333.333')

        self._update_tracking_summary()
        ckan.lib.search.rebuild()

        response = tests.call_action_api(app, 'package_search',
                                         sort='views_total desc')
        assert response['count'] == 3
        assert response['sort'] == 'views_total desc'
        packages = response['results']
        assert packages[0]['name'] == 'use_of_weapons'
        assert packages[1]['name'] == 'the_player_of_games'
        assert packages[2]['name'] == 'consider_phlebas'
Exemplo n.º 41
0
    def test_read(self):
        from pylons import config
        from nose.exc import SkipTest
        if config.get('ckan.auth.profile', '') != 'publisher':
            raise SkipTest('Publisher auth profile not enabled')

        # Relies on the search index being available
        setup_test_search_index()
        name = u'david'
        title = u'Dave\'s books'
        pkgname = u'warandpeace'
        group = model.Group.by_name(name)
        assert 'organization' == group.type
        for group_ref in (group.name, group.id):
            offset = url_for(controller='group', action='read', id=group_ref)
            res = self.app.get(offset)
            main_res = self.main_div(res)
            assert title in res, res
            assert 'Administrators' in res, res
            assert 'russianfan' in main_res, main_res
            assert name in res, res
            assert '0 datasets found.' in self.strip_tags(main_res), main_res
Exemplo n.º 42
0
    def setup_class(self):
        super(TestActionPackageSearch, self).setup_class()
        setup_test_search_index()
        self.package_fixture_data_1 = {
            'name': u'test-spatial-dataset-search-point-1',
            'title': 'Some Title 1',
            'extras': [{
                'key': 'spatial',
                'value': self.geojson_examples['point']
            }]
        }
        self.package_fixture_data_2 = {
            'name':
            u'test-spatial-dataset-search-point-2',
            'title':
            'Some Title 2',
            'extras': [{
                'key': 'spatial',
                'value': self.geojson_examples['point_2']
            }]
        }

        CreateTestData.create()
    def setup_class(cls):
        setup_test_search_index()
        # Force a garbage collection to trigger issue #695
        import gc
        gc.collect()

        CreateTestData.create()

        cls.new_pkg_dict = {
            'name': 'council-owned-litter-bins',
            'notes': 'Location of Council owned litter bins within Borough.',
            'resources': [{'description': 'Resource locator',
                           'format': 'Unverified',
                           'url': 'http://www.barrowbc.gov.uk'}],
            'tags': ['Utility and governmental services'],
            'title': 'Council Owned Litter Bins',
            'extras': {
                'INSPIRE': 'True',
                'bbox-east-long': '-3.12442',
                'bbox-north-lat': '54.218407',
                'bbox-south-lat': '54.039634',
                'bbox-west-long': '-3.32485',
                'constraint': 'conditions unknown; (e) intellectual property rights;',
                'dataset-reference-date': [{'type': 'creation',
                                            'value': '2008-10-10'},
                                           {'type': 'revision',
                                            'value': '2009-10-08'}],
                'guid': '00a743bf-cca4-4c19-a8e5-e64f7edbcadd',
                'metadata-date': '2009-10-16',
                'metadata-language': 'eng',
                'published_by': 0,
                'resource-type': 'dataset',
                'spatial-reference-system': 'test-spatial',
                'temporal_coverage-from': '1977-03-10T11:45:30',
                'temporal_coverage-to': '2005-01-15T09:10:00'
            }
        }
    def setup_class(cls):
        setup_test_search_index()
        # Force a garbage collection to trigger issue #695
        import gc
        gc.collect()

        CreateTestData.create()

        cls.new_pkg_dict = {
            "name": "council-owned-litter-bins",
            "notes": "Location of Council owned litter bins within Borough.",
            "resources": [{"description": "Resource locator",
                           "format": "Unverified",
                           "url": "http://www.barrowbc.gov.uk"}],
            "tags": ["Utility and governmental services"],
            "title": "Council Owned Litter Bins",
            "extras": {
                "INSPIRE": "True",
                "bbox-east-long": "-3.12442",
                "bbox-north-lat": "54.218407",
                "bbox-south-lat": "54.039634",
                "bbox-west-long": "-3.32485",
                "constraint": "conditions unknown; (e) intellectual property rights;",
                "dataset-reference-date": [{"type": "creation",
                                            "value": "2008-10-10"},
                                           {"type": "revision",
                                            "value": "2009-10-08"}],
                "guid": "00a743bf-cca4-4c19-a8e5-e64f7edbcadd",
                "metadata-date": "2009-10-16",
                "metadata-language": "eng",
                "published_by": 0,
                "resource-type": "dataset",
                "spatial-reference-system": "wee",
                "temporal_coverage-from": "1977-03-10T11:45:30",
                "temporal_coverage-to": "2005-01-15T09:10:00"
            }
        }
 def setup_class(cls):
     setup_test_search_index()
     init_data = [
         {
             'name': 'eng',
             'extras': {
                 'geographic_coverage': '100000: England'
             },
         },
         {
             'name': 'eng_ni',
             'extras': {
                 'geographic_coverage': '100100: England, Northern Ireland'
             },
         },
         {
             'name': 'uk',
             'extras': {
                 'geographic_coverage':
                 '111100: United Kingdom (England, Scotland, Wales, Northern Ireland'
             },
         },
         {
             'name': 'gb',
             'extras': {
                 'geographic_coverage':
                 '111000: Great Britain (England, Scotland, Wales)'
             },
         },
         {
             'name': 'none',
             'extras': {
                 'geographic_coverage': '000000:'
             },
         },
     ]
     CreateTestData.create_arbitrary(init_data)
 def setup_class(cls):
     setup_test_search_index()
     CreateTestData.create()
Exemplo n.º 47
0
 def setup_class(self):
     setup_test_search_index()
     model.Session.remove()
     CreateTestData.create()
Exemplo n.º 48
0
 def setup_class(cls):
     setup_test_search_index()
     CreateTestData.create()
     cls.solr = search.make_connection()
     cls.fq = " +site_id:\"%s\" " % config['ckan.site_id']
Exemplo n.º 49
0
 def setup_class(self):
     setup_test_search_index()
     self._create_test_data()
     model.Session.remove()
Exemplo n.º 50
0
 def setup_class(cls):
     setup_test_search_index()
     PylonsTestCase.setup_class()
     model.repo.init_db()
     CreateTestData.create()
Exemplo n.º 51
0
 def setup_class(cls):
     PylonsTestCase.setup_class()
     setup_test_search_index()
     CreateTestData.create()
Exemplo n.º 52
0
 def setup_class(cls):
     model.Session.remove()
     setup_test_search_index()
     CreateTestData.create_search_test_data()
     cls.count_re = re.compile('<strong>(\d)</strong> datasets found')
Exemplo n.º 53
0
 def setup_class(self):
     setup_test_search_index()
     self._create_test_data()
     model.Session.remove()
Exemplo n.º 54
0
 def setup_class(cls):
     setup_test_search_index()
     CreateTestData.create()
     cls.solr = search.make_connection()
     cls.fq = " +site_id:\"%s\" " % config['ckan.site_id']
Exemplo n.º 55
0
 def setup_class(self):
     setup_test_search_index()
     model.Session.remove()
     CreateTestData.create()
Exemplo n.º 56
0
 def setup_class(cls):
     setup_test_search_index()
     PylonsTestCase.setup_class()
     model.repo.init_db()
     CreateTestData.create()