Skip to content

Commit

Permalink
bands test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklvsa committed Oct 23, 2024
1 parent fb63661 commit 01f87ed
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_cli_estimate_cu.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,49 @@ def test_cli_estimate_cu_tileset_with_zoom_overrides(
result.output
== f"\nEstimated CUs for '{tileset_id}': {msg['cu']}. To publish your tileset, run 'tilesets publish'.\n"
)


@pytest.mark.usefixtures("token_environ")
@pytest.mark.usefixtures("api_environ")
@mock.patch("requests.Session.get")
@mock.patch("glob.glob")
def test_cli_estimate_cu_tileset_with_bands_override(
mock_glob, mock_request_get, MockResponse
):
runner = CliRunner()

tileset_id = "my.tileset"
msg = {"cu": "5"}

mock_request_get.return_value = MockResponse(msg)
mock_glob.return_value = ["myfile.grib2"]
result = runner.invoke(
estimate_cu,
[
tileset_id,
"-s",
"/my/sources/*.grib2",
"-b",
10,
"--minzoom",
1,
"--maxzoom",
6,
],
)
mock_request_get.assert_called_with(
f"https://api.mapbox.com/tilesets/v1/{tileset_id}/estimate",
params={
"minzoom": 1,
"maxzoom": 6,
"filesize": 0,
"band_count": 10,
"access_token": "pk.eyJ1IjoidGVzdC11c2VyIn0K",
},
)

assert result.exit_code == 0
assert (
result.output
== f"\nEstimated CUs for '{tileset_id}': {msg['cu']}. To publish your tileset, run 'tilesets publish'.\n"
)

0 comments on commit 01f87ed

Please sign in to comment.