Skip to content

Commit 1364d5a

Browse files
authored
update publish message with studio.mapbox.com link (#132)
* update publish message with studio.mapbox.com link * fix other pre-commit errors * update message with job command * update and pin black versions * update flake8 repo * pre-commit run --all-files * update language to "job received" * 1.7.0
1 parent 8a58b89 commit 1364d5a

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ repos:
22
-
33
repo: 'https://github.com/ambv/black'
44
# 18.6b1
5-
rev: stable
5+
rev: 20.8b1
66
hooks:
77
- id: black
88
args: ['--safe']
99
-
10-
repo: 'https://github.com/pre-commit/pre-commit-hooks'
11-
rev: v2.0.0
10+
repo: 'https://gitlab.com/pycqa/flake8'
11+
rev: 3.9.0
1212
hooks:
1313
- id: flake8
1414
args: [

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased
22

3+
# 1.7.0 (2021-04-02)
4+
- Update `tilesets publish` success message to include link to studio.mapbox.com/tilesets/* endpoint and include `tilesets job` command to view the status.
5+
36
# 1.6.0 (2021-02-16)
47
- Fix problem that prevented estimate-area from working for MultiPolygons
58
- Improve documentation for delete-source and upload-source
@@ -8,10 +11,10 @@
811
- Update README for estimate-area
912

1013
# 1.5.0 (2020-10-19)
11-
- Create estimate-area command
14+
- Create estimate-area command
1215

1316
# 1.4.3 (2020-10-08)
14-
- Update Click version to 7.1.2 and fix assertions to pass all tests
17+
- Update Click version to 7.1.2 and fix assertions to pass all tests
1518

1619
# 1.4.2 (2020-08-18)
1720
- Check if the token matches the username before uploading sources

mapbox_tilesets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""mapbox_tilesets package"""
22

3-
__version__ = "1.6.0"
3+
__version__ = "1.7.0"

mapbox_tilesets/scripts/cli.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,19 @@ def publish(tileset, token=None, indent=None):
119119
)
120120
r = s.post(url)
121121
if r.status_code == 200:
122-
click.echo(json.dumps(r.json(), indent=indent))
122+
response_msg = r.json()
123+
click.echo(json.dumps(response_msg, indent=indent))
124+
125+
studio_url = click.style(
126+
f"https://studio.mapbox.com/tilesets/{tileset}", bold=True
127+
)
128+
job_id = response_msg["jobId"]
129+
job_cmd = click.style(f"tilesets job {tileset} {job_id}", bold=True)
130+
message = f"\n✔ Tileset job received. Visit {studio_url} or run {job_cmd} to view the status of your tileset."
131+
# print(message)
123132
click.echo(
124-
f"You can view the status of your tileset with the `tilesets status {tileset}` command.",
125-
err=True,
133+
message,
134+
err=True, # print to stderr so the JSON output can be parsed separately from the success message
126135
)
127136
else:
128137
raise errors.TilesetsError(r.text)

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ def read(fname):
4040
include_package_data=True,
4141
zip_safe=False,
4242
extras_require={
43-
"test": ["pytest==4.6.11", "pytest-cov", "pre-commit", "black", "pep8"]
43+
"test": [
44+
"pytest==4.6.11",
45+
"pytest-cov",
46+
"pre-commit",
47+
"black==20.8b1",
48+
"pep8",
49+
"toml==0.10.2",
50+
]
4451
},
4552
entry_points="""
4653
[console_scripts]

tests/test_cli_publish.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ def test_cli_publish(mock_request_post):
2626
runner = CliRunner()
2727

2828
# sends expected request
29-
mock_request_post.return_value = MockResponse({"message": "mock message"}, 200)
29+
mock_request_post.return_value = MockResponse(
30+
{"message": "mock message", "jobId": "1234fakejob"}, 200
31+
)
3032
result = runner.invoke(publish, ["test.id"])
3133
mock_request_post.assert_called_with(
3234
"https://api.mapbox.com/tilesets/v1/test.id/publish?access_token=pk.eyJ1IjoidGVzdC11c2VyIn0K"
3335
)
3436
assert result.exit_code == 0
37+
print(result.output)
3538
assert (
36-
"You can view the status of your tileset with the `tilesets status test.id` command."
39+
'{"message": "mock message", "jobId": "1234fakejob"}\n\n✔ Tileset job received. Visit https://studio.mapbox.com/tilesets/test.id or run tilesets job test.id 1234fakejob to view the status of your tileset.\n'
3740
in result.output
3841
)
3942

@@ -42,14 +45,16 @@ def test_cli_publish(mock_request_post):
4245
@mock.patch("requests.Session.post")
4346
def test_cli_publish_use_token_flag(mock_request_post):
4447
runner = CliRunner()
45-
mock_request_post.return_value = MockResponse({"message": "mock message"}, 200)
48+
mock_request_post.return_value = MockResponse(
49+
{"message": "mock message", "jobId": "1234fakejob"}, 200
50+
)
4651
# Provides the flag --token
4752
result = runner.invoke(publish, ["test.id", "--token", "flag-token"])
4853
mock_request_post.assert_called_with(
4954
"https://api.mapbox.com/tilesets/v1/test.id/publish?access_token=flag-token"
5055
)
5156
assert result.exit_code == 0
5257
assert (
53-
"You can view the status of your tileset with the `tilesets status test.id` command."
58+
'{"message": "mock message", "jobId": "1234fakejob"}\n\n✔ Tileset job received. Visit https://studio.mapbox.com/tilesets/test.id or run tilesets job test.id 1234fakejob to view the status of your tileset.\n'
5459
in result.output
5560
)

0 commit comments

Comments
 (0)