Skip to content

Commit ec1d245

Browse files
committed
format
1 parent 3860846 commit ec1d245

File tree

4 files changed

+56
-49
lines changed

4 files changed

+56
-49
lines changed

rsconnect/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def deploy(
521521
title_is_default: bool,
522522
tarball: IO[bytes],
523523
env_vars: Optional[dict[str, str]] = None,
524-
activate: bool = True
524+
activate: bool = True,
525525
) -> RSConnectClientDeployResult:
526526
if app_id is None:
527527
if app_name is None:
@@ -1008,7 +1008,7 @@ def upload_posit_bundle(self, prepare_deploy_result: PrepareDeployResult, bundle
10081008
upload_result = S3Server(upload_url).handle_bad_response(upload_result, is_httpresponse=True)
10091009

10101010
@cls_logged("Deploying bundle ...")
1011-
def deploy_bundle(self, activate: bool=True):
1011+
def deploy_bundle(self, activate: bool = True):
10121012
if self.deployment_name is None:
10131013
raise RSConnectException("A deployment name must be created before deploying a bundle.")
10141014
if self.bundle is None:

rsconnect/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def content_args(func: Callable[P, T]) -> Callable[P, T]:
293293
help=(
294294
"Deploy the application as a draft. "
295295
"Previous bundle will continue to be served until the draft is published."
296-
)
296+
),
297297
)
298298
@functools.wraps(func)
299299
def wrapper(*args: P.args, **kwargs: P.kwargs):
@@ -1407,7 +1407,7 @@ def deploy_tensorflow(
14071407
env_vars: dict[str, str],
14081408
image: Optional[str],
14091409
no_verify: bool,
1410-
draft: bool
1410+
draft: bool,
14111411
):
14121412
set_verbosity(verbose)
14131413
output_params(ctx, locals().items())
@@ -1658,7 +1658,7 @@ def deploy_app(
16581658
token: Optional[str],
16591659
secret: Optional[str],
16601660
no_verify: bool,
1661-
draft: bool
1661+
draft: bool,
16621662
):
16631663
set_verbosity(verbose)
16641664
entrypoint = validate_entry_point(entrypoint, directory)

tests/test_environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def fake_inspect_environment(
272272
assert environment.python_interpreter == expected_python
273273
assert environment == expected_environment
274274

275+
275276
class TestEnvironmentDeprecations:
276277
def test_override_python_version(self):
277278
with mock.patch.object(rsconnect.environment.logger, "warning") as mock_warning:

tests/test_main.py

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,18 @@ def test_deploy(self):
9999

100100
@pytest.mark.parametrize(
101101
"command, target,expected_activate",
102-
[args + [flag] for flag in [True, False] for args in [
103-
["notebook", get_dir(join("pip1", "dummy.ipynb"))],
104-
["html", get_manifest_path("pyshiny_with_manifest", "")],
105-
["manifest", get_manifest_path("pyshiny_with_manifest", "")],
106-
["quarto", get_manifest_path("pyshiny_with_manifest", "")],
107-
["tensorflow", get_api_path("pyshiny_with_manifest", "")],
108-
["voila", get_dir(join("pip1", "dummy.ipynb"))],
109-
]],
102+
[
103+
args + [flag]
104+
for flag in [True, False]
105+
for args in [
106+
["notebook", get_dir(join("pip1", "dummy.ipynb"))],
107+
["html", get_manifest_path("pyshiny_with_manifest", "")],
108+
["manifest", get_manifest_path("pyshiny_with_manifest", "")],
109+
["quarto", get_manifest_path("pyshiny_with_manifest", "")],
110+
["tensorflow", get_api_path("pyshiny_with_manifest", "")],
111+
["voila", get_dir(join("pip1", "dummy.ipynb"))],
112+
]
113+
],
110114
)
111115
@httpretty.activate(verbose=True, allow_net_connect=False)
112116
def test_deploy_draft(self, command, target, expected_activate):
@@ -129,55 +133,62 @@ def test_deploy_draft(self, command, target, expected_activate):
129133
)
130134
httpretty.register_uri(
131135
httpretty.GET,
132-
"http://fake_server/__api__/applications"
133-
"?search=app5&count=100",
136+
"http://fake_server/__api__/applications?search=app5&count=100",
134137
body=open("tests/testdata/rstudio-responses/get-applications.json", "r").read(),
135138
adding_headers={"Content-Type": "application/json"},
136139
status=200,
137140
)
138141
httpretty.register_uri(
139142
httpretty.POST,
140143
"http://fake_server/__api__/applications",
141-
body=json.dumps({
142-
"id": "1234-5678-9012-3456",
143-
"guid": "1234-5678-9012-3456",
144-
"title": "app5",
145-
"url": "http://fake_server/apps/1234-5678-9012-3456",
146-
}),
144+
body=json.dumps(
145+
{
146+
"id": "1234-5678-9012-3456",
147+
"guid": "1234-5678-9012-3456",
148+
"title": "app5",
149+
"url": "http://fake_server/apps/1234-5678-9012-3456",
150+
}
151+
),
147152
adding_headers={"Content-Type": "application/json"},
148153
status=200,
149154
)
150155
httpretty.register_uri(
151156
httpretty.POST,
152157
"http://fake_server/__api__/applications/1234-5678-9012-3456",
153-
body=json.dumps({
154-
"id": "1234-5678-9012-3456",
155-
"guid": "1234-5678-9012-3456",
156-
"title": "app5",
157-
"url": "http://fake_server/apps/1234-5678-9012-3456",
158-
}),
158+
body=json.dumps(
159+
{
160+
"id": "1234-5678-9012-3456",
161+
"guid": "1234-5678-9012-3456",
162+
"title": "app5",
163+
"url": "http://fake_server/apps/1234-5678-9012-3456",
164+
}
165+
),
159166
adding_headers={"Content-Type": "application/json"},
160167
status=200,
161168
)
162169
httpretty.register_uri(
163170
httpretty.GET,
164171
"http://fake_server/__api__/applications/1234-5678-9012-3456",
165-
body=json.dumps({
166-
"id": "1234-5678-9012-3456",
167-
"guid": "1234-5678-9012-3456",
168-
"title": "app5",
169-
"url": "http://fake_server/apps/1234-5678-9012-3456"
170-
}),
172+
body=json.dumps(
173+
{
174+
"id": "1234-5678-9012-3456",
175+
"guid": "1234-5678-9012-3456",
176+
"title": "app5",
177+
"url": "http://fake_server/apps/1234-5678-9012-3456",
178+
}
179+
),
171180
adding_headers={"Content-Type": "application/json"},
172181
status=200,
173182
)
174183

175184
httpretty.register_uri(
176185
httpretty.POST,
177186
"http://fake_server/__api__/applications/1234-5678-9012-3456/upload",
178-
body=json.dumps({
179-
"id": "FAKE_BUNDLE_ID",
180-
}),
187+
body=json.dumps(
188+
{
189+
"id": "FAKE_BUNDLE_ID",
190+
}
191+
),
181192
adding_headers={"Content-Type": "application/json"},
182193
status=200,
183194
)
@@ -186,27 +197,22 @@ def test_deploy_draft(self, command, target, expected_activate):
186197
# We can check that the process actually submits the draft
187198
def post_application_deploy_callback(request, uri, response_headers):
188199
parsed_request = _load_json(request.body)
189-
expectation = {'bundle': 'FAKE_BUNDLE_ID'}
200+
expectation = {"bundle": "FAKE_BUNDLE_ID"}
190201
if not expected_activate:
191-
expectation['activate'] = False
202+
expectation["activate"] = False
192203
assert parsed_request == expectation
193-
return [
194-
200,
195-
{"Content-Type": "application/json"},
196-
json.dumps({"id": "FAKE_TASK_ID"})
197-
]
204+
return [200, {"Content-Type": "application/json"}, json.dumps({"id": "FAKE_TASK_ID"})]
198205

199206
httpretty.register_uri(
200207
httpretty.POST,
201208
"http://fake_server/__api__/applications/1234-5678-9012-3456/deploy",
202-
body=post_application_deploy_callback
209+
body=post_application_deploy_callback,
203210
)
204211

205212
# Fake deploy task completion
206213
httpretty.register_uri(
207214
httpretty.GET,
208-
"http://fake_server/__api__/v1/tasks/FAKE_TASK_ID"
209-
"?wait=1",
215+
"http://fake_server/__api__/v1/tasks/FAKE_TASK_ID" "?wait=1",
210216
body=json.dumps({"output": ["FAKE_OUTPUT"], "last": "FAKE_LAST", "finished": True, "code": 0}),
211217
adding_headers={"Content-Type": "application/json"},
212218
status=200,
@@ -220,15 +226,15 @@ def post_application_deploy_callback(request, uri, response_headers):
220226
status=200,
221227
)
222228

223-
224229
try:
225230
runner = CliRunner()
226231
args = apply_common_args(["deploy", command, target], server="http://fake_server", key="FAKE_API_KEY")
227232
args.append("--no-verify")
228233
if not expected_activate:
229234
args.append("--draft")
230-
with mock.patch("rsconnect.main.which_quarto", return_value=None), \
231-
mock.patch("rsconnect.main.quarto_inspect", return_value={}):
235+
with mock.patch("rsconnect.main.which_quarto", return_value=None), mock.patch(
236+
"rsconnect.main.quarto_inspect", return_value={}
237+
):
232238
result = runner.invoke(cli, args)
233239
assert result.exit_code == 0, result.output
234240
finally:

0 commit comments

Comments
 (0)