o2r-project / geoextent

Python library for extrating geospatial extent of files and directories with multiple data formats
https://o2r.info/geoextent/
MIT License
1 stars 4 forks source link

Create test suite using pytest #5

Closed YouQam closed 4 years ago

nuest commented 5 years ago

Make sure there are tests for both the CLI and the Python library interface.

Maybe this helps with the CLI testing, based on test files from https://github.com/o2r-project/o2r-meta/tree/master/extract/tests

lat,lon,name,time
10,20,münster,2018
11,50,berlin,2017

--------

def test_csv_bbox(script_runner, tmpdir):
    ret = script_runner.run('python3', 'geoextent',
        '--path', 'testdata/dataset.csv', 
        '--detail', 'bbox')
    #print(ret.stdout)
    assert ret.success, "process should return success"
    assert ret.stderr == '', "stderr should be empty"
    assert "[[10,20],[11,50]" in ret.stdout, " bbox is printed to console"

def test_csv_time(script_runner, tmpdir):
    ret = script_runner.run('python3', 'geoextent',
        '--path', 'testdata/dataset.csv', 
        '--detail', 'bbox',
        '--time')
    #print(ret.stdout)
    assert ret.success, "process should return success"
    assert ret.stderr == '', "stderr should be empty"
    assert "temporal extent is from 2017 ==> 2018" in ret.stdout, " temporal bbox is printed to console"

------

lat,lon,name,time
10,20,münster,2018
11,50,berlin,2017
1,2,city,abcd

def test_csv_time_invalid(script_runner, tmpdir):
    ret = script_runner.run('python3', 'geoextent',
        '--path', 'testdata/dataset_invalid_time.csv', 
        '--detail', 'bbox',
        '--time')
    #print(ret.stdout)
    assert not ret.success, "process should return success"
    assert ret.stderr == 'invalid time format', "stderr should not be empty"