Ejemplo n.º 1
0
def is_netcdf_url(url):
    # type: (Any) -> bool
    if not isinstance(url, str):
        return False
    if urlparse(url).scheme == "":
        return False
    return os.path.splitext(url)[-1] == get_extension(CONTENT_TYPE_APP_NETCDF)
Ejemplo n.º 2
0
def test_get_cwl_file_format_synonym():
    """
    Test handling of special non-official MIME-type that have a synonym redirection to an official one.
    """
    res = f.get_cwl_file_format(f.ContentType.APP_TAR_GZ,
                                make_reference=False,
                                must_exist=True,
                                allow_synonym=False)
    assert res == (
        None, None
    ), "Non-official MIME-type without allowed synonym should resolve as not-found"
    res = f.get_cwl_file_format(f.ContentType.APP_TAR_GZ,
                                make_reference=False,
                                must_exist=True,
                                allow_synonym=True)
    assert isinstance(res, tuple)
    assert res != (
        None,
        None), "Synonym type should have been mapped to its base reference"
    assert res[1].split(
        ":"
    )[1] == f.ContentType.APP_GZIP, "Synonym type should have been mapped to its base reference"
    assert f.get_extension(
        f.ContentType.APP_TAR_GZ
    ) == ".tar.gz", "Original extension resolution needed, not synonym"
    fmt = f.get_format(f.ContentType.APP_TAR_GZ)
    assert fmt.extension == ".tar.gz"
    assert fmt.mime_type == f.ContentType.APP_TAR_GZ
    # above tests validated that synonym is defined and works, so following must not use that synonym
    res = f.get_cwl_file_format(f.ContentType.APP_TAR_GZ,
                                make_reference=True,
                                must_exist=False,
                                allow_synonym=True)
    assert res.endswith(f.ContentType.APP_TAR_GZ), \
        "Literal MIME-type expected instead of its existing synonym since non-official is allowed (must_exist=False)"
Ejemplo n.º 3
0
def test_get_extension():
    assert f.get_extension(f.ContentType.APP_JSON) == ".json"  # basic
    assert f.get_extension(f.ContentType.APP_JSON + "; charset=UTF-8"
                           ) == ".json"  # ignore extra parameters
    assert f.get_extension(
        f.ContentType.APP_GEOJSON) == ".geojson"  # pywps <4.4 definition
    assert f.get_extension(
        f.ContentType.APP_VDN_GEOJSON) == ".geojson"  # pywps>=4.4 definition
    assert f.get_extension(
        f.ContentType.IMAGE_GEOTIFF) == ".tiff"  # pywps definition
    assert f.get_extension("application/x-custom") == ".custom"
    assert f.get_extension("application/unknown") == ".unknown"
Ejemplo n.º 4
0
def test_get_extension_glob_any():
    assert f.get_extension(f.ContentType.ANY) == ".*"
Ejemplo n.º 5
0
def test_get_extension_glob_any():
    assert f.get_extension(f.CONTENT_TYPE_ANY) == ".*"