Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_with_obj(feature_seq, runner):
result = runner.invoke(main_group, ['bounds', '--with-obj'], feature_seq)
assert result.exit_code == 0
assert result.output.count('geometry') == result.output.count('bbox') == 2
def test_dump(path_coutwildrnp_shp):
runner = CliRunner()
result = runner.invoke(main_group, ['dump', path_coutwildrnp_shp])
assert result.exit_code == 0
assert '"FeatureCollection"' in result.output
def test_fio_ls_single_layer(data_dir):
result = CliRunner().invoke(main_group, ['ls', data_dir])
assert result.exit_code == 0
assert len(result.output.splitlines()) == 1
assert sorted(json.loads(result.output)) == ['coutwildrnp', 'gre', 'test_tin']
def test_collection(tmpdir, feature_collection, runner):
tmpfile = str(tmpdir.mkdir('tests').join('test_collection.shp'))
result = runner.invoke(
main_group, ['load', '-f', 'Shapefile', tmpfile], feature_collection)
assert result.exit_code == 0
assert len(fiona.open(tmpfile)) == 2
def test_distrib(feature_collection_pp):
runner = CliRunner()
result = runner.invoke(main_group, ['distrib', ], feature_collection_pp)
assert result.exit_code == 0
assert result.output.count('"Feature"') == 2
def test_fail(runner):
result = runner.invoke(main_group, ['filter',
"f.properties.test > 5"
], "{'type': 'no_properties'}")
assert result.exit_code == 1
def test_collect_noparse_rs(feature_seq_pp_rs):
runner = CliRunner()
result = runner.invoke(
main_group, ['collect', '--no-parse'],
feature_seq_pp_rs,
catch_exceptions=False)
assert result.exit_code == 0
assert result.output.count('"Feature"') == 2
assert len(json.loads(result.output)['features']) == 2
def test_bbox_yes(path_coutwildrnp_shp):
runner = CliRunner()
result = runner.invoke(
main_group,
['cat', path_coutwildrnp_shp, '--bbox', '-109,37,-107,39'],
catch_exceptions=False)
assert result.exit_code == 0
assert result.output.count('"Feature"') == 19
def test_seq(feature_seq, runner):
result = runner.invoke(main_group, ['filter',
"f.properties.AREA > 0.01"], feature_seq)
assert result.exit_code == 0
assert result.output.count('Feature') == 2
result = runner.invoke(main_group, ['filter',
"f.properties.AREA > 0.015"], feature_seq)
assert result.exit_code == 0
assert result.output.count('Feature') == 1
result = runner.invoke(main_group, ['filter',
"f.properties.AREA > 0.02"], feature_seq)
assert result.exit_code == 0
assert result.output.count('Feature') == 0
def test_info_json():
runner = CliRunner()
result = runner.invoke(main_group, ['info', WILDSHP])
assert result.exit_code == 0
assert '"count": 67' in result.output
assert '"crs": "EPSG:4326"' in result.output
assert '"driver": "ESRI Shapefile"' in result.output
assert '"name": "coutwildrnp"' in result.output