def table_resource_with_invalid_schema(valid_dataset): resource = Resource() resource.url = "http://smth.smwhere.com" resource.title = "File resource name" resource.type = "file" resource.format = 'XLSX' resource.file = File(open(prepare_file('wrong_schema_table.xlsx'), 'rb')) resource.file.open('rb') resource.dataset = valid_dataset resource.save() return resource
def valid_resource_with_file(valid_dataset, file_csv): resource = Resource() resource.title = "File resource name" resource.resource_type = "Table" resource.type = "file" resource.format = 'csv' resource.file = File(file_csv) resource.file.open('r') resource.dataset = valid_dataset resource.tracker.saved_data['link'] = resource.link resource.save() return resource
def no_data_resource(dataset): resource = Resource() resource.title = "No data resource" resource.type = "file" resource.format = 'JPG' if not is_enabled('S40_new_file_model.be'): resource.file = File(open(prepare_file('buzzfeed-logo.jpg'), 'rb')) resource.file.open('rb') resource.dataset = dataset resource.save() if is_enabled('S40_new_file_model.be'): ResourceFile.objects.create(file=File( open(prepare_file('buzzfeed-logo.jpg'), 'rb')), is_main=True, resource=resource, format='JPG') resource = Resource.objects.get(pk=resource.pk) return resource