def _create_datasets(self): """ create the required datasets to test """ log.info('Creating datasets for testing collections') # create just one time if hasattr(self, 'org1'): return reset_db # TODO it's seems not working self.org1 = ckan_factories.Organization() log.info('Org1 created {}'.format(self.org1['id'])) self.org2 = ckan_factories.Organization() log.info('Org2 created {}'.format(self.org2['id'])) self.group1 = ckan_factories.Group() log.info('Group1 created {}'.format(self.group1['id'])) self.group2 = ckan_factories.Group() log.info('Group2 created {}'.format(self.group2['id'])) self.parent = ckan_factories.Dataset(owner_org=self.org1['id'], extras=[{'key': 'collection_metadata', 'value': 'true'}], title='The Father test_collections_unique', groups=[{'name': self.group1['name']}, {'name': self.group2['name']}]) log.info('Parent created {}'.format(self.parent['id'])) self.child1 = ckan_factories.Dataset(owner_org=self.org1['id'], extras=[{'key': 'collection_package_id', 'value': self.parent['id']}], title='The Child 2 test_collections_unique', groups=[{'name': self.group1['name']}]) log.info('Child 1 created {}'.format(self.child1['id'])) self.child2 = ckan_factories.Dataset(owner_org=self.org1['id'], extras=[{'key': 'collection_package_id', 'value': self.parent['id']}], title='The Child 2 test_collections_unique', groups=[{'name': self.group2['name']}]) log.info('Child 2 created {}'.format(self.child2['id']))
def test_group_list_with_results(self): group1 = factories.Group(name='water') group2 = factories.Group(name='transportation') group3 = factories.Group(name='economy') group_from_helpers = get_group_list() assert group_from_helpers[0]['name'] == 'economy' assert group_from_helpers[1]['name'] == 'transportation' assert group_from_helpers[2]['name'] == 'water'
def test_package_create_with_group_permission(self): user = factories.User(name='user2') owner_org = factories.Organization(users=[{ 'name': user['name'], 'capacity': 'editor' }]) group = factories.Group(name='economy', users=[{ 'name': user['name'], 'capacity': 'member' }]) context = {'user': user['name'], 'ignore_auth': False} params = { 'name': 'test-dataset-2', 'notes': 'This is a test', 'tag_string': 'geography', 'accessLevel': 'public', 'contact_name': 'John Smith', 'contact_email': '*****@*****.**', 'rights': 'No restrictions on public use', 'accrualPeriodicity': 'R/P1W', 'owner_org': owner_org['id'], 'group': 'economy' } dataset = helpers.call_action('package_create', context=context, **params) assert dataset['groups'][0]['name'] == 'economy'
def test_selected_group_with_several_groups(self): group1 = factories.Group(name='economy') group2 = factories.Group(name='transportation') group3 = factories.Group(name='water') dataset = factories.Dataset(tag_string='geography', accessLevel='public', contact_name='John Smith', contact_email='*****@*****.**', rights='No restrictions on public use', accrualPeriodicity='R/P1W', groups=[{ 'name': group2['name'] }, { 'name': group3['name'] }]) assert get_selected_group(dataset) == 'transportation'
def test_group_pages_index(self, app): user = factories.Sysadmin() env = {'REMOTE_USER': user['name'].encode('ascii')} group = factories.Group() endpoint = 'pages.group_pages_index' if ckan_29_or_higher else 'group_pages_index' url = toolkit.url_for(endpoint, id=group['id']) response = app.get(url, status=200, extra_environ=env) assert '<h2>Pages</h2>' in response.body assert 'Add page</a>' in response.body
def setup(self): uid = str(int(time.time()) + 2) name = "test_org" + uid organization = factories.Organization(name=name) group_1 = "test_group_1" + uid group_2 = "test_group_2" + uid self.group1 = factories.Group(name=group_1) self.group2 = factories.Group(name=group_2) dataset_1 = "test_dataset_1" + uid dataset_2 = "test_dataset_2" + uid self.dataset1 = factories.Dataset(name=dataset_1, owner_org=organization['id'], groups=[{ "name": self.group1["name"] }]) self.dataset2 = factories.Dataset(name=dataset_2, owner_org=organization['id'], groups=[{ "name": self.group2["name"] }])
def test_package_patch_with_group_modifier(self): group1 = factories.Group(name='economy') group2 = factories.Group(name='transportation') group3 = factories.Group(name='water') dataset = factories.Dataset(name='test-dataset-3', tag_string='geography', accessLevel='public', contact_name='John Smith', contact_email='*****@*****.**', rights='No restrictions on public use', accrualPeriodicity='R/P1W', group='economy') assert dataset['groups'][0]['name'] == 'economy' dataset = helpers.call_action('package_patch', id='test-dataset-3', group='transportation') assert dataset['groups'][0]['name'] == 'transportation' assert len(dataset['groups']) == 1
def test_package_create_with_group_modifier(self): group1 = factories.Group(name='economy') dataset = factories.Dataset(name='test-dataset-2', tag_string='geography', accessLevel='public', contact_name='John Smith', contact_email='*****@*****.**', rights='No restrictions on public use', accrualPeriodicity='R/P1W', group='economy') assert dataset['groups'][0]['name'] == 'economy'