Skip to content

Commit

Permalink
feat: add support for the rasterarray type on the list command. (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
theborowski authored May 8, 2024
1 parent 561f295 commit 9a9b5a7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
venv/
build/
develop-eggs/
dist/
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

=======

# 1.10.0 (2024-05-07)
- Add support for the `rasterarray` type on the `list` command.

# 1.9.3 (2023-06-27)
- Beautified error messages

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ tilesets list <username>

Flags:

- `--type [vector|raster]` [optional]: filter results by tileset type
- `--type [vector|raster|rasterarray]` [optional]: filter results by tileset type
- `--visibility [public|private]` [optional]: filter results by visibility
- `--sortby [created|modified]` [optional]: sort results by their `created` or `modified` timestamps
- `--limit [1-500]` [optional]: the maximum number of results to return, from 1 to 500. The default is 100.
Expand Down
2 changes: 1 addition & 1 deletion mapbox_tilesets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""mapbox_tilesets package"""

__version__ = "1.9.3"
__version__ = "1.10.0"
2 changes: 1 addition & 1 deletion mapbox_tilesets/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def job(tileset, job_id, token=None, indent=None):
@click.option(
"--type",
required=False,
type=click.Choice(["vector", "raster"]),
type=click.Choice(["vector", "raster", "rasterarray"]),
help="Filter results by tileset type",
)
@click.option(
Expand Down
26 changes: 4 additions & 22 deletions tests/test_cli_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def test_cli_list_bad_token(mock_request_get, MockResponse):

@pytest.mark.usefixtures("token_environ")
@mock.patch("requests.Session.get")
def test_cli_list_type_vector(mock_request_get, MockResponse):
@pytest.mark.parametrize("type", ["vector", "raster", "rasterarray"])
def test_cli_list_type(mock_request_get, MockResponse, type):
runner = CliRunner()

message = [
Expand All @@ -76,28 +77,9 @@ def test_cli_list_type_vector(mock_request_get, MockResponse):
]

mock_request_get.return_value = MockResponse(message)
result = runner.invoke(list, ["test", "--type", "vector"])
result = runner.invoke(list, ["test", "--type", type])
mock_request_get.assert_called_with(
"https://api.mapbox.com/tilesets/v1/test?access_token=pk.eyJ1IjoidGVzdC11c2VyIn0K&limit=100&type=vector"
)
assert result.exit_code == 0
assert result.output == """test.tileset-1\ntest.tileset-2\n"""


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

message = [
{"id": "test.tileset-1", "something": "beep"},
{"id": "test.tileset-2", "something": "boop"},
]

mock_request_get.return_value = MockResponse(message)
result = runner.invoke(list, ["test", "--type", "raster"])
mock_request_get.assert_called_with(
"https://api.mapbox.com/tilesets/v1/test?access_token=pk.eyJ1IjoidGVzdC11c2VyIn0K&limit=100&type=raster"
f"https://api.mapbox.com/tilesets/v1/test?access_token=pk.eyJ1IjoidGVzdC11c2VyIn0K&limit=100&type={type}"
)
assert result.exit_code == 0
assert result.output == """test.tileset-1\ntest.tileset-2\n"""
Expand Down

0 comments on commit 9a9b5a7

Please sign in to comment.