Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
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
Esempio n. 9
0
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
Esempio n. 10
0
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
Esempio n. 11
0
 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
Esempio n. 12
0
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