@@ -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