rasterio/tests/test__env.py
Sean Gillies 36786d5886
GDAL 3.0.x support in code but not wheels (#1729)
* Added support for Proj6 and GDAL 3

* install proj6

* build proj with local installation dir

* conditional proj dependency

* added proj4 flags for all gdal versions

* Restore debian data tests

* Version specific proj configuration

* Fix string comp expression

* Explicit matrix

* Restructure build matrix

* Remove wait from proj build script

* Call script with bash

* Fix version text

* Bash syntax

* Correct PROJOPTs

* Use xvfb service

* Back to proj 4.8 for older GDAL

* Fix syntax error

* Add verbosity to tests

* Take proj off library path, remove gdal-bin package

* Install PROJ and GDAL to same prefix

* Set up runtime env

* Try 4.9.3

* Source build scripts

* Switch to case for versions

* set trace

* Test existence of share/gdal directory

The proj install script created the gdal install directory so a
test for just that is not sufficient.

* Test for share/proj

* Run tests under gdb

* Forgot the run command

* Wait 20 for GDAL

* travis_wait

* Restructure build script, less boilerplate

* Back to trusty

* dist: trusty

* Remove gdb

* Allow 3.0.1/6.1.1 to fail, some changes since 3.0.0/6.1.0
2019-07-26 13:46:55 -06:00

127 lines
3.9 KiB
Python

"""Tests of _env util module"""
import pytest
from rasterio._env import GDALDataFinder, PROJDataFinder
from .conftest import gdal_version, requires_gdal_lt_3
@pytest.fixture
def mock_wheel(tmpdir):
"""A fake rasterio wheel"""
moduledir = tmpdir.mkdir("rasterio")
moduledir.ensure("__init__.py")
moduledir.ensure("_env.py")
moduledir.ensure("gdal_data/pcs.csv")
moduledir.ensure("proj_data/epsg")
return moduledir
@pytest.fixture
def mock_fhs(tmpdir):
"""A fake FHS system"""
tmpdir.ensure("share/gdal/pcs.csv")
tmpdir.ensure("share/proj/epsg")
return tmpdir
@pytest.fixture
def mock_debian(tmpdir):
"""A fake Debian multi-install system"""
tmpdir.ensure("share/gdal/1.11/pcs.csv")
tmpdir.ensure("share/gdal/2.0/pcs.csv")
tmpdir.ensure("share/gdal/2.1/pcs.csv")
tmpdir.ensure("share/gdal/2.2/pcs.csv")
tmpdir.ensure("share/gdal/2.3/pcs.csv")
tmpdir.ensure("share/gdal/2.4/pcs.csv")
tmpdir.ensure("share/gdal/3.0/pcs.csv")
tmpdir.ensure("share/proj/epsg")
return tmpdir
def test_search_wheel_gdal_data_failure(tmpdir):
"""Fail to find GDAL data in a non-wheel"""
finder = GDALDataFinder()
assert not finder.search_wheel(str(tmpdir))
def test_search_wheel_gdal_data(mock_wheel):
"""Find GDAL data in a wheel"""
finder = GDALDataFinder()
assert finder.search_wheel(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("gdal_data"))
def test_search_prefix_gdal_data_failure(tmpdir):
"""Fail to find GDAL data in a bogus prefix"""
finder = GDALDataFinder()
assert not finder.search_prefix(str(tmpdir))
def test_search_prefix_gdal_data(mock_fhs):
"""Find GDAL data under prefix"""
finder = GDALDataFinder()
assert finder.search_prefix(str(mock_fhs)) == str(mock_fhs.join("share").join("gdal"))
def test_search_debian_gdal_data_failure(tmpdir):
"""Fail to find GDAL data in a bogus Debian location"""
finder = GDALDataFinder()
assert not finder.search_debian(str(tmpdir))
def test_search_debian_gdal_data(mock_debian):
"""Find GDAL data under Debian locations"""
finder = GDALDataFinder()
assert finder.search_debian(str(mock_debian)) == str(mock_debian.join("share").join("gdal").join("{}".format(str(gdal_version))))
def test_search_gdal_data_wheel(mock_wheel):
finder = GDALDataFinder()
assert finder.search(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("gdal_data"))
def test_search_gdal_data_fhs(mock_fhs):
finder = GDALDataFinder()
assert finder.search(str(mock_fhs)) == str(mock_fhs.join("share").join("gdal"))
def test_search_gdal_data_debian(mock_debian):
"""Find GDAL data under Debian locations"""
finder = GDALDataFinder()
assert finder.search(str(mock_debian)) == str(mock_debian.join("share").join("gdal").join("{}".format(str(gdal_version))))
def test_search_wheel_proj_data_failure(tmpdir):
"""Fail to find GDAL data in a non-wheel"""
finder = PROJDataFinder()
assert not finder.search_wheel(str(tmpdir))
def test_search_wheel_proj_data(mock_wheel):
"""Find GDAL data in a wheel"""
finder = PROJDataFinder()
assert finder.search_wheel(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("proj_data"))
def test_search_prefix_proj_data_failure(tmpdir):
"""Fail to find GDAL data in a bogus prefix"""
finder = PROJDataFinder()
assert not finder.search_prefix(str(tmpdir))
def test_search_prefix_proj_data(mock_fhs):
"""Find GDAL data under prefix"""
finder = PROJDataFinder()
assert finder.search_prefix(str(mock_fhs)) == str(mock_fhs.join("share").join("proj"))
def test_search_proj_data_wheel(mock_wheel):
finder = PROJDataFinder()
assert finder.search(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("proj_data"))
def test_search_proj_data_fhs(mock_fhs):
finder = PROJDataFinder()
assert finder.search(str(mock_fhs)) == str(mock_fhs.join("share").join("proj"))