def institution_with_id_and_datasets_and_removed_datasets( institution_id, num, rm_num): org = OrganizationFactory.create( id=institution_id, title='Institution {} with datasets.'.format(institution_id)) DatasetFactory.create_batch(num, organization=org) DatasetFactory.create_batch(rm_num, organization=org, is_removed=True) return org
def datasets_with_resources_of_type(datasets_data): data = json.loads(datasets_data) for item in data: _dataset = DatasetFactory.create() for res_type, res_count in item.items(): ResourceFactory.create_batch(res_count, dataset=_dataset, type=res_type) time.sleep(1) # time to index data before request is made.
def showcase_with_id_and_datasets(showcase_id, num): showcase = ShowcaseFactory.create( id=showcase_id, title='showcase {} with datasets'.format(showcase_id)) datasets = DatasetFactory.create_batch(num, showcases=(showcase, )) for dataset in datasets: ResourceFactory.create_batch(3, dataset=dataset) return showcase
def active_editor(): usr = EditorFactory.create(email='*****@*****.**', password='******', phone='0048123456789') org = OrganizationFactory.create(users=(usr, )) ds = DatasetFactory.create(organization=org) ResourceFactory.create_batch(2, dataset=ds) return usr
def application_with_id_and_datasets(application_id, num): application = ApplicationFactory.create( id=application_id, title='application {} with datasets'.format(application_id)) datasets = DatasetFactory.create_batch(num, applications=(application, )) for dataset in datasets: ResourceFactory.create_batch(3, dataset=dataset) return application
def three_datasets_with_different_created_at(dates): dates_ = dates.split("|") datasets = [] for d in dates_: d = parser.parse(d) ds = DatasetFactory.create(created=d) datasets.append(ds) return datasets
def dataset_with_resource_and_params(field_name, field_value): _dataset = DatasetFactory.create() kwargs = { field_name: field_value } ResourceFactory.create(dataset=_dataset, **kwargs) CategoryFactory.create_batch(2, datasets=(_dataset,)) return _dataset
def dataset_with_chart_as_visualization_type(): _dataset = DatasetFactory.create() _resource = ResourceFactory( dataset=_dataset, link='https://github.com/frictionlessdata/goodtables-py/blob/master/data/valid.csv', ) ChartFactory.create(resource=_resource, is_default=True) _dataset.save() return _dataset
def dataset_with_id_and_resources(dataset_id, slug): _dataset = DatasetFactory.create(id=dataset_id, slug=slug) ResourceFactory.create_batch(2, dataset=_dataset) return _dataset
def second_dataset_with_id(dataset_id): _dataset = DatasetFactory.create(id=dataset_id, title='Second dataset %s' % dataset_id) return _dataset
def removed_dataset(): _dataset = DatasetFactory.create(is_removed=True, title='Removed dataset') return _dataset
def dataset(): _dataset = DatasetFactory.create() TagFactory.create_batch(2, datasets=(_dataset,)) return _dataset
def dataset_with_resource(): _dataset = DatasetFactory.create() ResourceFactory.create(dataset=_dataset) CategoryFactory.create_batch(2, datasets=(_dataset,)) return _dataset
def application_with_datasets(): org = ApplicationFactory.create() DatasetFactory.create_batch(2, application=org) return org
def article_with_datasets(): _article = ArticleFactory.create(title='Article with datasets') DatasetFactory.create_batch(2, articles=(_article, )) return _article
def number_of_datasets_with_resources_with_type(number_of_datasets, num, res_type): for x in range(number_of_datasets): _dataset = DatasetFactory.create() ResourceFactory.create_batch(num, dataset=_dataset, type=res_type)
def dataset_with_title_and_x_resources(title, num): _dataset = DatasetFactory.create(title=title) ResourceFactory.create_batch(num, dataset=_dataset) return _dataset
def dataset_with_id_and_showcases(dataset_id, num): _dataset = DatasetFactory.create(id=dataset_id, title='dataset {} with showcases'.format(dataset_id)) for x in range(num): ShowcaseFactory.create(title=f'Ponowne wykorzystanie {x+1}', datasets=[_dataset]) return _dataset
def dataset_with_id_and_datasets(dataset_id, num): _dataset = DatasetFactory.create(id=dataset_id, title='dataset {} with resources'.format(dataset_id)) ResourceFactory.create_batch(num, dataset=_dataset) return _dataset
def dataset_with_id(dataset_id): _dataset = DatasetFactory.create( id=dataset_id, title=f'test dataset with id {dataset_id}', ) return _dataset
def another_dataset_with_id(dataset_id): _dataset = DatasetFactory.create(id=dataset_id, title='Another dataset %s' % dataset_id) return _dataset
def add_dataset_to_article(dataset_id, article_id): instance = ArticleFactory._meta.model.objects.get(pk=article_id) dataset_instance = DatasetFactory(pk=dataset_id) instance.datasets.add(dataset_instance)
def dataset_with_resources(): _dataset = DatasetFactory.create() ResourceFactory.create_batch(2, dataset=_dataset) return _dataset
def showcase_with_datasets(): showcase = ShowcaseFactory.create() DatasetFactory.create_batch(2, showcase=showcase) return showcase
def imported_ckan_resource(): _source = DataSourceFactory.create(source_type='CKAN', name='Test name', portal_url='http://example.com') _dataset = DatasetFactory.create(source=_source) _resource = ResourceFactory.create(dataset=_dataset) return _resource
def imported_dataset(dataset_data, source_type, name, portal_url): dataset_data = json.loads(dataset_data) _source = DataSourceFactory.create(source_type=source_type, name=name, portal_url=portal_url) _dataset = DatasetFactory.create(source=_source, **dataset_data) ResourceFactory.create(dataset=_dataset) return _dataset
def x_datasets(num): return DatasetFactory.create_batch(num)
def imported_resource_of_type(resource_id, source_type, name, portal_url, res_type): _source = DataSourceFactory.create(source_type=source_type, name=name, portal_url=portal_url) _dataset = DatasetFactory.create(source=_source) _resource = ResourceFactory.create(id=resource_id, dataset=_dataset, type=res_type) return _resource
def datasets(): return DatasetFactory.create_batch(3)
def article_with_id_with_datasets(article_id, num): _article = ArticleFactory.create( id=article_id, title='Article {} with datasets'.format(article_id)) DatasetFactory.create_batch(num, articles=(_article, )) return _article