def setup(self):
        th.reset_db()
        search.clear_all()
        user = factories.User()
        other_user = factories.User()
        simple_user = factories.User()
        org = factories.Organization(users=[{
            'name': user['name'],
            'capacity': 'editor'
        }, {
            'name': other_user['name'],
            'capacity': 'editor'
        }])
        self.user = user
        self.other_user = other_user
        self.simple_user = simple_user
        self.org = org

        pkg = factories.Dataset(user=user, owner_org=org['id'])
        th.call_action('move_to_next_stage', id=pkg['id'])
        data = th.call_action('move_to_next_stage', id=pkg['id'])
        nt.assert_equal(data['workflow_stage'], 'published')
        pkg = factories.Dataset(user=user, owner_org=org['id'])
        data = th.call_action('move_to_next_stage', id=pkg['id'])
        nt.assert_equal(data['workflow_stage'], 'pending')
        pkg = factories.Dataset(user=user, owner_org=org['id'])
        nt.assert_equal(pkg['workflow_stage'], 'unpublished')
Exemple #2
0
    def setup_class(cls):
        search.clear_all()
        model.Session.add_all([
            model.User(name=u'sysadmin', apikey=u'sysadmin',
                       password=u'sysadmin', sysadmin=True),
        ])
        model.Session.commit()

        data_dict = '%s=1' % json.dumps({
            'name': 'org',
        })
        res = cls.app.post('/api/action/organization_create',
                            extra_environ={'Authorization': 'sysadmin'},
                            params=data_dict)
        cls.org_id = json.loads(res.body)['result']['id']

        cls.package_ids = []
        for i in range(0,12):
            data_dict = '%s=1' % json.dumps({
                'name': 'name{i}'.format(i=i),
                'owner_org': 'org',
            })
            res = cls.app.post('/api/action/package_create',
                                extra_environ={'Authorization': 'sysadmin'},
                                params=data_dict)
            cls.package_ids.append(json.loads(res.body)['result']['id'])
Exemple #3
0
    def setup_class(cls):
        search.clear_all()
        model.Session.add_all([
            model.User(name=u'sysadmin', apikey=u'sysadmin',
                       password=u'sysadmin', sysadmin=True),
        ])
        model.Session.commit()

        data_dict = '%s=1' % json.dumps({
            'name': 'org',
        })
        res = cls.app.post('/api/action/organization_create',
                            extra_environ={'Authorization': 'sysadmin'},
                            params=data_dict)
        cls.org_id = json.loads(res.body)['result']['id']

        cls.package_ids = []
        for i in range(0,12):
            data_dict = '%s=1' % json.dumps({
                'name': 'name{i}'.format(i=i),
                'owner_org': 'org',
            })
            res = cls.app.post('/api/action/package_create',
                                extra_environ={'Authorization': 'sysadmin'},
                                params=data_dict)
            cls.package_ids.append(json.loads(res.body)['result']['id'])
Exemple #4
0
 def setup_class(cls):
     model.repo.rebuild_db()
     search.clear_all()
     CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
     cls.normal_user = model.User.get('annafan')
     CreateTestData.make_some_vocab_tags()
 def setup_class(cls):
     if not p.plugin_loaded(u"datastore"):
         p.load(u"datastore")
     reset_db()
     search.clear_all()
     engine = db.get_write_engine()
     rebuild_all_dbs(orm.scoped_session(orm.sessionmaker(bind=engine)))
Exemple #6
0
 def setup_class(cls):
     model.repo.rebuild_db()
     search.clear_all()
     CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
     cls.normal_user = model.User.get('annafan')
     CreateTestData.make_some_vocab_tags()
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.testsysadmin = model.User.by_name(u'testsysadmin')
     cls.comment = u'Comment umlaut: \xfc.'
     cls.user_name = u'annafan'  # created in CreateTestData
     cls.init_extra_environ(cls.user_name)
Exemple #8
0
def clear(dataset_name):
    from ckan.lib.search import clear, clear_all

    if dataset_name:
        clear(dataset_name)
    else:
        clear_all()
Exemple #9
0
def clear(dataset_name: str):
    from ckan.lib.search import clear, clear_all

    if dataset_name:
        clear(dataset_name)
    else:
        clear_all()
Exemple #10
0
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.testsysadmin = model.User.by_name(u'testsysadmin')
     cls.comment = u'Comment umlaut: \xfc.'
     cls.user_name = u'annafan' # created in CreateTestData
     cls.init_extra_environ(cls.user_name)
Exemple #11
0
    def setup_class(self):
        search.clear_all()
        model.Session.remove()
        CreateTestData.create()

        # reduce extraneous logging
        from ckan.lib import activity_streams_session_extension
        activity_streams_session_extension.logger.level = 100
 def initial_data(self):
     # clean the db so we can run these tests on their own
     model.repo.rebuild_db()
     search.clear_all()
     CreateTestData.create()
     yield
     model.repo.rebuild_db()
     model.Session.remove()
Exemple #13
0
    def setup_class(self):
        search.clear_all()
        model.Session.remove()
        CreateTestData.create()

        # reduce extraneous logging
        from ckan.lib import activity_streams_session_extension
        activity_streams_session_extension.logger.level = 100
Exemple #14
0
    def test_purged_dataset_is_not_in_search_results(self):
        search.clear_all()
        dataset = factories.Dataset()

        def get_search_results():
            results = helpers.call_action("package_search", q=dataset["title"])["results"]
            return [d["name"] for d in results]

        assert_equals(get_search_results(), [dataset["name"]])

        helpers.call_action("dataset_purge", id=dataset["name"])

        assert_equals(get_search_results(), [])
Exemple #15
0
    def test_purged_dataset_is_not_in_search_results(self):
        search.clear_all()
        dataset = factories.Dataset()

        def get_search_results():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return [d['name'] for d in results]
        assert_equals(get_search_results(), [dataset['name']])

        helpers.call_action('dataset_purge', id=dataset['name'])

        assert_equals(get_search_results(), [])
Exemple #16
0
    def test_purged_dataset_is_not_in_search_results(self):
        search.clear_all()
        dataset = factories.Dataset()

        def get_search_results():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return [d['name'] for d in results]
        assert_equals(get_search_results(), [dataset['name']])

        helpers.call_action('dataset_purge', id=dataset['name'])

        assert_equals(get_search_results(), [])
Exemple #17
0
    def test_purged_org_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org['id'])

        def get_search_result_owner_org():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return results[0]['owner_org']
        assert_equals(get_search_result_owner_org(), org['id'])

        helpers.call_action('organization_purge', id=org['name'])

        assert_equals(get_search_result_owner_org(), None)
Exemple #18
0
    def test_purged_group_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        group = factories.Group()
        dataset = factories.Dataset(groups=[{'name': group['name']}])

        def get_search_result_groups():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return [g['name'] for g in results[0]['groups']]
        assert_equals(get_search_result_groups(), [group['name']])

        helpers.call_action('group_purge', id=group['name'])

        assert_equals(get_search_result_groups(), [])
Exemple #19
0
    def test_purged_group_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        group = factories.Group()
        dataset = factories.Dataset(groups=[{"name": group["name"]}])

        def get_search_result_groups():
            results = helpers.call_action("package_search", q=dataset["title"])["results"]
            return [g["name"] for g in results[0]["groups"]]

        assert_equals(get_search_result_groups(), [group["name"]])

        helpers.call_action("group_purge", id=group["name"])

        assert_equals(get_search_result_groups(), [])
Exemple #20
0
    def test_purged_group_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        group = factories.Group()
        dataset = factories.Dataset(groups=[{'name': group['name']}])

        def get_search_result_groups():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return [g['name'] for g in results[0]['groups']]
        assert_equals(get_search_result_groups(), [group['name']])

        helpers.call_action('group_purge', id=group['name'])

        assert_equals(get_search_result_groups(), [])
Exemple #21
0
    def test_purged_org_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org['id'])

        def get_search_result_owner_org():
            results = helpers.call_action('package_search',
                                          q=dataset['title'])['results']
            return results[0]['owner_org']
        assert_equals(get_search_result_owner_org(), org['id'])

        helpers.call_action('organization_purge', id=org['name'])

        assert_equals(get_search_result_owner_org(), None)
Exemple #22
0
    def test_purged_org_is_not_in_search_results_for_its_ex_dataset(self):
        search.clear_all()
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org["id"])

        def get_search_result_owner_org():
            results = helpers.call_action("package_search", q=dataset["title"])["results"]
            return results[0]["owner_org"]

        assert_equals(get_search_result_owner_org(), org["id"])

        helpers.call_action("organization_purge", id=org["name"])

        assert_equals(get_search_result_owner_org(), None)
Exemple #23
0
    def setup_class(cls):
        cls.original_config = config.copy()

        # so that we can search for strings in the HTTP response
        config['ckan.use_pylons_response_cleanup_middleware'] = False
        cls._change_config(config)

        search.clear_all()
        helpers.reset_db()
        caching.invalidate_group_caches()
        # cls._load_plugins()
        cls.app = _get_test_app()

        cls.replace_package_create()

        cls._create_test_data()
Exemple #24
0
    def setup_class(cls):
        search.clear_all()
        helpers.reset_db()

        cls.original_config = config.copy()
        cls._change_config(config)

        cls.m_s3 = mock_s3()
        cls.m_s3.start()

        cls.conn = boto3.resource(
            's3', region_name=config['ckanext.s3filestore.region_name'])
        cls.conn.create_bucket(Bucket=cls.bucket_name)

        app = helpers._get_test_app()

        factories.Sysadmin(name='testsysadmin')
        cls._create_packages_by_user(cls.dataset1_name, 'testsysadmin')
 def teardown(self):
     helpers.reset_db()
     search.clear_all()
Exemple #26
0
 def setup(self):
     """Reset the database and clear the search indexes."""
     reset_db()
     if hasattr(self, "_test_app"):
         self._test_app.reset()
     search.clear_all()
Exemple #27
0
    def setup_class(cls):
        # clean the db so we can run these tests on their own
        model.repo.rebuild_db()
        search.clear_all()
        CreateTestData.create()

        cls.package_expected = {
            u"author": None,
            u"author_email": None,
            u"creator_user_id": None,
            "extras": [
                {u"key": u"genre", u"state": u"active", u"value": "romantic novel"},
                {u"key": u"original media", u"state": u"active", u"value": u"book"},
            ],
            "groups": [
                {
                    u"name": u"david",
                    u"capacity": u"public",
                    u"image_url": u"",
                    u"image_display_url": u"",
                    u"description": u"These are books that David likes.",
                    u"display_name": u"Dave's books",
                    u"type": u"group",
                    u"state": u"active",
                    u"is_organization": False,
                    u"title": u"Dave's books",
                    u"approval_status": u"approved",
                },
                {
                    u"name": u"roger",
                    u"capacity": u"public",
                    u"description": u"Roger likes these books.",
                    u"image_url": u"",
                    "image_display_url": u"",
                    "display_name": u"Roger's books",
                    u"type": u"group",
                    u"state": u"active",
                    u"is_organization": False,
                    u"title": u"Roger's books",
                    u"approval_status": u"approved",
                },
            ],
            "isopen": True,
            u"license_id": u"other-open",
            "license_title": u"Other (Open)",
            "organization": None,
            u"owner_org": None,
            u"maintainer": None,
            u"maintainer_email": None,
            u"name": u"annakarenina",
            u"notes": u"Some test notes\n\n### A 3rd level heading\n\n**Some bolded text.**\n\n*Some italicized text.*\n\nForeign characters:\nu with umlaut \xfc\n66-style quote \u201c\nforeign word: th\xfcmb\n\nNeeds escaping:\nleft arrow <\n\n<http://ckan.net/>\n\n",
            "num_resources": 2,
            "num_tags": 3,
            u"private": False,
            "relationships_as_object": [],
            "relationships_as_subject": [],
            "resources": [
                {
                    u"alt_url": u"alt123",
                    u"cache_last_updated": None,
                    u"cache_url": None,
                    u"description": u'Full text. Needs escaping: " Umlaut: \xfc',
                    u"format": u"plain text",
                    u"hash": u"abc123",
                    u"last_modified": None,
                    u"mimetype": None,
                    u"mimetype_inner": None,
                    u"name": None,
                    u"position": 0,
                    u"resource_type": None,
                    u"size": None,
                    u"size_extra": u"123",
                    u"url_type": None,
                    u"state": u"active",
                    u"url": u"http://datahub.io/download/x=1&y=2",
                },
                {
                    u"alt_url": u"alt345",
                    u"cache_last_updated": None,
                    u"cache_url": None,
                    u"description": u"Index of the novel",
                    u"format": u"JSON",
                    u"hash": u"def456",
                    u"last_modified": None,
                    u"mimetype": None,
                    u"mimetype_inner": None,
                    u"name": None,
                    u"position": 1,
                    u"resource_type": None,
                    u"url_type": None,
                    u"size": None,
                    u"size_extra": u"345",
                    u"state": u"active",
                    u"url": u"http://datahub.io/index.json",
                },
            ],
            u"state": u"active",
            "tags": [
                {u"name": u"Flexible \u30a1", "display_name": u"Flexible \u30a1", u"state": u"active"},
                {"display_name": u"russian", u"name": u"russian", u"state": u"active"},
                {"display_name": u"tolstoy", u"name": u"tolstoy", u"state": u"active"},
            ],
            u"title": u"A Novel By Tolstoy",
            u"type": u"dataset",
            u"url": u"http://datahub.io",
            u"version": u"0.7a",
        }
Exemple #28
0
 def setup_class(self):
     search.clear_all()
     model.Session.remove()
     CreateTestData.create()
Exemple #29
0
 def setup(self):
     '''Reset the database and clear the search indexes.'''
     reset_db()
     if hasattr(self, '_test_app'):
         self._test_app.reset()
     search.clear_all()
Exemple #30
0
 def setup(self):
     """Reset the database and clear the search indexes."""
     reset_db()
     if hasattr(self, "_test_app"):
         self._test_app.reset()
     search.clear_all()
Exemple #31
0
 def setup_class(cls):
     p.load(u'datastore')
     reset_db()
     search.clear_all()
     engine = db.get_write_engine()
     rebuild_all_dbs(orm.scoped_session(orm.sessionmaker(bind=engine)))
Exemple #32
0
 def setup(self):
     '''Reset the database and clear the search indexes.'''
     reset_db()
     search.clear_all()
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
Exemple #34
0
 def setup_class(self):
     search.clear_all()
     model.Session.remove()
     CreateTestData.create()
 def setup(self):
     helpers.reset_db()
     search.clear_all()
Exemple #36
0
def setup_test_search_index():
    # from ckan import plugins
    if not is_search_supported():
        pytest.skip("Search not supported")
    search.clear_all()
Exemple #37
0
    def setup_class(cls):
        # clean the db so we can run these tests on their own
        model.repo.rebuild_db()
        search.clear_all()
        CreateTestData.create()

        cls.package_expected = {
            u'author': None,
            u'author_email': None,
            u'creator_user_id': None,
            'extras': [
                # extras are no longer revisioned so we get the latest version
                {'key': u'david', 'state': u'active', 'value': u'new_value'},
                {'key': u'genre', 'state': u'active', 'value': u'new_value'},
                {'key': u'original media', 'state': u'active',
                 'value': u'book'}
               ],
            'groups': [{
                        u'name': u'david',
                        u'capacity': u'public',
                        u'image_url': u'',
                        u'image_display_url': u'',
                        u'description': u'These are books that David likes.',
                        u'display_name': u"Dave's books",
                        u'type': u'group',
                        u'state': u'active',
                        u'is_organization': False,
                        u'title': u"Dave's books",
                        u"approval_status": u"approved"},
                       {
                        u'name': u'roger',
                        u'capacity': u'public',
                        u'description': u'Roger likes these books.',
                        u'image_url': u'',
                        'image_display_url': u'',
                        'display_name': u"Roger's books",
                        u'type': u'group',
                        u'state': u'active',
                        u'is_organization': False,
                        u'title': u"Roger's books",
                        u"approval_status": u"approved"}],
            'isopen': True,
            u'license_id': u'other-open',
            'license_title': u'Other (Open)',
            'organization': None,
            u'owner_org': None,
            u'maintainer': None,
            u'maintainer_email': None,
            u'name': u'annakarenina',
            u'notes': u'Some test notes\n\n### A 3rd level heading\n\n**Some bolded text.**\n\n*Some italicized text.*\n\nForeign characters:\nu with umlaut \xfc\n66-style quote \u201c\nforeign word: th\xfcmb\n\nNeeds escaping:\nleft arrow <\n\n<http://ckan.net/>\n\n',
            'num_resources': 2,
            'num_tags': 3,
            u'private': False,
            'relationships_as_object': [],
            'relationships_as_subject': [],
            'resources': [{u'alt_url': u'alt123',
                            u'cache_last_updated': None,
                            u'cache_url': None,
                            u'description': u'Full text. Needs escaping: " Umlaut: \xfc',
                            u'format': u'plain text',
                            u'hash': u'abc123',
                            u'last_modified': None,
                            u'mimetype': None,
                            u'mimetype_inner': None,
                            u'name': None,
                            u'position': 0,
                            u'resource_type': None,
                            u'size': None,
                            u'size_extra': u'123',
                            u'url_type': None,
                            u'state': u'active',
                            u'url': u'http://datahub.io/download/x=1&y=2',},
                           {u'alt_url': u'alt345',
                            u'cache_last_updated': None,
                            u'cache_url': None,
                            u'description': u'Index of the novel',
                            u'format': u'JSON',
                            u'hash': u'def456',
                            u'last_modified': None,
                            u'mimetype': None,
                            u'mimetype_inner': None,
                            u'name': None,
                            u'position': 1,
                            u'resource_type': None,
                            u'url_type': None,
                            u'size': None,
                            u'size_extra': u'345',
                            u'state': u'active',
                            u'url': u'http://datahub.io/index.json'}],
            u'state': u'active',
            'tags': [{u'name': u'Flexible \u30a1',
                        'display_name': u'Flexible \u30a1',
                        u'state': u'active'},
                     {'display_name': u'russian',
                         u'name': u'russian',
                         u'state': u'active'},
                     {'display_name': u'tolstoy',
                         u'name': u'tolstoy',
                         u'state': u'active'}],
            u'title': u'A Novel By Tolstoy',
            u'type': u'dataset',
            u'url': u'http://datahub.io',
            u'version': u'0.7a',
            }
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
Exemple #39
0
 def setup(self):
     '''Reset the database and clear the search indexes.'''
     reset_db()
     if hasattr(self, '_test_app'):
         self._test_app.reset()
     search.clear_all()
 def teardown(self):
     helpers.reset_db()
     search.clear_all()
Exemple #41
0
def setup_test_search_index():
    #from ckan import plugins
    if not is_search_supported():
        raise SkipTest("Search not supported")
    search.clear_all()
Exemple #42
0
def setup_test_search_index():
    #from ckan import plugins
    if not is_search_supported():
        raise SkipTest("Search not supported")
    search.clear_all()
Exemple #43
0
 def setup(self):
     """Reset the database and clear the search indexes."""
     reset_db()
     search.clear_all()
Exemple #44
0
 def teardown_class(cls):
     model.repo.rebuild_db()
     search.clear_all()
Exemple #45
0
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
Exemple #46
0
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.user_name = u'russianfan' # created in CreateTestData
     cls.init_extra_environ(cls.user_name)
Exemple #47
0
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.user_name = u"russianfan"  # created in CreateTestData
     cls.init_extra_environ(cls.user_name)
Exemple #48
0
 def setup_class(cls):
     search.clear_all()
     CreateTestData.create()
     cls.sysadmin_user = model.User.get('testsysadmin')
Exemple #49
0
 def setup(self):
     helpers.reset_db()
     search.clear_all()
     CreateTestData.create()
     make_package_revision(model.Package.by_name('annakarenina'))
Exemple #50
0
 def setup(self):
     helpers.reset_db()
     search.clear_all()
 def setupClass(self):
     helpers.reset_db()
     clear_all()