From 8f5c6ca237868a9b223ac7b41088b64d8525f468 Mon Sep 17 00:00:00 2001 From: marcosnav Date: Mon, 30 Jun 2025 12:24:03 -0600 Subject: [PATCH 1/3] Update content draft URL --- rsconnect/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index a095d273..26548956 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -570,10 +570,10 @@ def deploy( task = self.content_deploy(app_guid, app_bundle["id"], activate=activate) - # http://ADDRESS/preview/APP_GUID/BUNDLE_ID - # Using replace makes this a bit more robust to changes in the URL structure - # like connect being served on a subpath. - preview_url = app["url"].replace("/content/", "/preview/").rstrip("/") + f"/{app_bundle['id']}" + # http://ADDRESS/DASHBOARD-PATH/#/apps/GUID/draft/BUNDLE_ID_TO_PREVIEW + # Pulling v1 content to get the full dashboard URL + app_v1 = self.content_get(app["guid"]) + preview_url = app_v1["dashboard_url"] + f"/draft/{app_bundle['id']}" return { "task_id": task["task_id"], From c80e58a02a4335d3731d5f2e5892d210e80de003 Mon Sep 17 00:00:00 2001 From: marcosnav Date: Mon, 30 Jun 2025 13:25:28 -0600 Subject: [PATCH 2/3] Use draft terminology. Update tests for Draft URL --- rsconnect/api.py | 12 ++++++------ tests/test_main.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 26548956..894487a3 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -335,7 +335,7 @@ class RSConnectClientDeployResult(TypedDict): app_id: str app_guid: str | None app_url: str - preview_url: str | None + draft_url: str | None title: str | None @@ -573,14 +573,14 @@ def deploy( # http://ADDRESS/DASHBOARD-PATH/#/apps/GUID/draft/BUNDLE_ID_TO_PREVIEW # Pulling v1 content to get the full dashboard URL app_v1 = self.content_get(app["guid"]) - preview_url = app_v1["dashboard_url"] + f"/draft/{app_bundle['id']}" + draft_url = app_v1["dashboard_url"] + f"/draft/{app_bundle['id']}" return { "task_id": task["task_id"], "app_id": app_id, "app_guid": app["guid"], "app_url": app["url"], - "preview_url": preview_url if not activate else None, + "draft_url": draft_url if not activate else None, "title": app["title"], } @@ -1090,7 +1090,7 @@ def deploy_bundle(self, activate: bool = True): app_id=str(prepare_deploy_result.app_id), app_guid=None, task_id=None, - preview_url=None, + draft_url=None, title=self.title, ) return self @@ -1132,8 +1132,8 @@ def emit_task_log( log_lines = self.remote_server.handle_bad_response(log_lines) log_callback.info("Deployment completed successfully.") - if self.deployed_info.get("preview_url"): - log_callback.info("\t Preview content URL: %s", self.deployed_info["preview_url"]) + if self.deployed_info.get("draft_url"): + log_callback.info("\t Draft content URL: %s", self.deployed_info["draft_url"]) else: app_config = self.client.app_config(self.deployed_info["app_id"]) app_config = self.remote_server.handle_bad_response(app_config) diff --git a/tests/test_main.py b/tests/test_main.py index 825decc1..3b9daa53 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -229,6 +229,18 @@ def post_application_deploy_callback(request, uri, response_headers): status=200, ) + httpretty.register_uri( + httpretty.GET, + "http://fake_server/__api__/v1/content/1234-5678-9012-3456", + body=json.dumps( + { + "dashboard_url": "http://fake_server/connect/#/apps/1234-5678-9012-3456", + } + ), + adding_headers={"Content-Type": "application/json"}, + status=200, + ) + try: runner = CliRunner() args = apply_common_args(["deploy", command, target], server="http://fake_server", key="FAKE_API_KEY") @@ -252,7 +264,7 @@ def post_application_deploy_callback(request, uri, response_headers): assert "Direct content URL: http://fake_server/content/1234-5678-9012-3456" in caplog.text else: assert ( - "Preview content URL: http://fake_server/preview/1234-5678-9012-3456/FAKE_BUNDLE_ID" in caplog.text + "Draft content URL: http://fake_server/connect/#/apps/1234-5678-9012-3456/draft/FAKE_BUNDLE_ID" in caplog.text ) finally: if original_api_key_value: From b178e312c4e3b1af401516b80d987ff547e3691d Mon Sep 17 00:00:00 2001 From: marcosnav Date: Mon, 30 Jun 2025 13:49:44 -0600 Subject: [PATCH 3/3] Lint --- tests/test_main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 3b9daa53..01b6ecbc 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -241,6 +241,8 @@ def post_application_deploy_callback(request, uri, response_headers): status=200, ) + expected_content_url = "http://fake_server/content/1234-5678-9012-3456" + expected_draft_url = "http://fake_server/connect/#/apps/1234-5678-9012-3456/draft/FAKE_BUNDLE_ID" try: runner = CliRunner() args = apply_common_args(["deploy", command, target], server="http://fake_server", key="FAKE_API_KEY") @@ -261,11 +263,9 @@ def post_application_deploy_callback(request, uri, response_headers): assert deploy_api_invoked == [True] assert "Deployment completed successfully." in caplog.text if expected_activate: - assert "Direct content URL: http://fake_server/content/1234-5678-9012-3456" in caplog.text + assert f"Direct content URL: {expected_content_url}" in caplog.text else: - assert ( - "Draft content URL: http://fake_server/connect/#/apps/1234-5678-9012-3456/draft/FAKE_BUNDLE_ID" in caplog.text - ) + assert f"Draft content URL: {expected_draft_url}" in caplog.text finally: if original_api_key_value: os.environ["CONNECT_API_KEY"] = original_api_key_value