Пример #1
0
def test__webresource__get_deepzoom_uri(settings):
    webresource = WebResource(spec=spec_name, uri=test_uri)
    deepzoom_uri = webresource.get_deepzoom_uri
    assert deepzoom_uri is not None
    assert settings.RDF_BASE_URL in deepzoom_uri
    assert webresource.get_derivative_base_path(kind=DEEPZOOM_DIR) in deepzoom_uri
    assert deepzoom_uri.endswith(".tif.dzi")
Пример #2
0
def test__webresource__get_derivative_base_path():
    webresource = WebResource(spec=spec_name)
    d_path = webresource.get_derivative_base_path(test_uri)
    assert d_path
    assert len(d_path.split('/')) == 6
    assert d_path.startswith(THUMBNAIL_DIR)
    assert webresource.get_derivative_base_path(
        test_uri,
        kind=DEEPZOOM_DIR
    ).startswith(DEEPZOOM_DIR)
Пример #3
0
def test__webresource__hub_id_extract_object_number(settings):
    test_object_number = "123"
    hub_id = "{}_{}_{}".format(settings.ORG_ID, spec_name, test_object_number)
    webresource = WebResource(spec=spec_name, uri=test_uri, hub_id=hub_id)
    assert webresource
    assert webresource._hub_id == hub_id
    assert webresource.hub_id == webresource._hub_id

    assert webresource.extract_object_number() == test_object_number
    webresource = WebResource(spec=spec_name, uri=test_uri)
Пример #4
0
def test__webresource__source_path_exists(tmpdir, settings):
    test_base = str(tmpdir)
    webresource = WebResource(spec=spec_name, base_dir=test_base, uri=test_uri)
    webresource.create_dataset_webresource_dirs()
    test_image = os.path.join(os.path.dirname(__file__), 'nasa_ares_logo.png')
    shutil.copy(test_image, webresource.uri_to_path)
    assert os.path.exists(webresource.uri_to_path)
    assert webresource.exists_source

    webresource = WebResource(spec=spec_name, base_dir=test_base, uri='urn:{}/fake_image.jpg'.format(webresource.spec))
    assert not os.path.exists(webresource.uri_to_path)
    assert not webresource.exists_source
Пример #5
0
def test__create_dataset_webresource_dir(tmpdir):
    test_base = str(tmpdir)
    webresource = WebResource(spec=spec_name, base_dir=test_base)
    assert webresource is not None
    assert webresource.base_dir == test_base
    assert len(os.listdir(test_base)) == 0
    assert not webresource.exist_webresource_dirs
    webresource.create_dataset_webresource_dirs()
    assert len(os.listdir(test_base)) != 0
    assert os.listdir(test_base) == [webresource.org_id]
    assert os.path.exists(
        os.path.join(webresource.get_spec_dir, THUMBNAIL_DIR)
    )
    assert webresource.exist_webresource_dirs
Пример #6
0
def create_webresource_dirs(endpoint=None):
    if endpoint is None:
        endpoint = rdfstore.get_sparql_base_url()

    from void.views import DataSetStatistics
    stats = DataSetStatistics(endpoint)
    specs = stats.get_spec_list(include_deleted=False)
    created_dirs = 0
    logger.info("Start syncing WebResource directories")
    for spec in specs.keys():
        logger.info(spec)
        from webresource.webresource import WebResource
        webresource = WebResource(spec=spec)
        created = webresource.create_dataset_webresource_dirs()
        if created:
            created_dirs += 1

    logger.info("Finished syncing WebResource directories. Created {}".format(created_dirs))
Пример #7
0
def test__webresource__create_hash():
    webresource = WebResource(spec=spec_name)
    sha256 = webresource.get_hash(test_uri)
    assert sha256
    assert sha256.startswith('d23a')