def valid_resource2(valid_dataset2): resource = Resource() resource.url = "http://smth.smwhere.com" resource.title = "Resource name2" resource.resource_type = "Table" resource.dataset = valid_dataset2 resource.save() return resource
def resource_in_dataset_org2(dataset_org2): resource = Resource() resource.url = "http://tokill.shadowthieves.bg/cowled_wizards" resource.title = "Zakapturzeni czarodzieje" resource.resource_type = "Table" resource.dataset = dataset_org2 resource.save() return resource
def draft_resource(valid_dataset2): resource = Resource() resource.link = "http://drafts.com" resource.title = "draft resource" resource.dataset = valid_dataset2 resource.status = "draft" resource.save() return resource
def removed_resource(valid_dataset2): resource = Resource() resource.link = "http://noth.nowhere.com" resource.title = "removed resource" resource.dataset = valid_dataset2 resource.is_removed = True resource.save() return resource
def valid_resource_with_description(valid_dataset): resource = Resource() resource.url = "http://smth.smwhere.com" resource.title = "Resource name" resource.description = "Test Resource Description" resource.dataset = valid_dataset resource.status = 'published' resource.save() return resource
def valid_resource2(valid_dataset2): resource = Resource() resource.link = "http://falconframework.org" resource.title = "Resource name2" resource.resource_type = "Table" resource.dataset = valid_dataset2 resource.tracker.saved_data['link'] = resource.link resource.tracker.saved_data['file'] = resource.file resource.save() return resource
def valid_resource(valid_dataset): resource = Resource() resource.link = "http://falconframework.org" resource.title = "Resource name" resource.resource_type = "Table" resource.dataset = valid_dataset resource.data_date = date.today() resource.tracker.saved_data['link'] = resource.link resource.save() return resource
def valid_resource_with_description(valid_dataset): resource = Resource() resource.link = "http://falconframework.org" resource.title = "Resource name" resource.description = "Test Resource Description" resource.dataset = valid_dataset resource.status = 'published' resource.tracker.saved_data['link'] = resource.link resource.tracker.saved_data['file'] = resource.file resource.save() return resource
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 test_resource_create(self, valid_dataset): r = Resource() # r.name = "test" r.title = "test" r.description = "Opis zasobu" r.format = "csv" r.resource_type = "zestawienie" r.old_resource_type = "zestawienie" r.dataset = valid_dataset r.link = "http://test.to.resource.pl/1.xls" r.data_date = "2018-10-02" assert r.full_clean() is None assert r.id is None r.save() assert r.id is not None
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