2121# would be preferable but this is fine for now.
2222TEMP_DIR = "rsconnect-build-test"
2323
24+
2425def register_uris (connect_server : str ):
2526 def register_content_endpoints (i : int , guid : str ):
2627 httpretty .register_uri (
@@ -38,10 +39,10 @@ def register_content_endpoints(i: int, guid: str):
3839 httpretty .register_uri (
3940 httpretty .GET ,
4041 f"{ connect_server } /__api__/applications/{ guid } /config" ,
41- body = '{' +
42- f'"config_url": "{ connect_server } /connect/#/apps/{ guid } ",' +
43- f'"logs_url": "{ connect_server } /connect/#/apps/{ guid } "' +
44- '}' ,
42+ body = "{"
43+ + f'"config_url": "{ connect_server } /connect/#/apps/{ guid } ",'
44+ + f'"logs_url": "{ connect_server } /connect/#/apps/{ guid } "'
45+ + "}" ,
4546 adding_headers = {"Content-Type" : "application/json" },
4647 )
4748
@@ -88,6 +89,7 @@ def register_content_endpoints(i: int, guid: str):
8889 register_content_endpoints (2 , "ab497e4b-b706-4ae7-be49-228979a95eb4" )
8990 register_content_endpoints (3 , "cdfed1f7-0e09-40eb-996d-0ef77ea2d797" )
9091
92+
9193class TestContentSubcommand (unittest .TestCase ):
9294 @classmethod
9395 def tearDownClass (cls ):
@@ -120,9 +122,14 @@ def test_content_search(self):
120122 def test_content_describe (self ):
121123 register_uris (self .connect_server )
122124 runner = CliRunner ()
123- args = ["content" , "describe" ,
124- "-g" , "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
125- "-g" , "ab497e4b-b706-4ae7-be49-228979a95eb4" ]
125+ args = [
126+ "content" ,
127+ "describe" ,
128+ "-g" ,
129+ "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
130+ "-g" ,
131+ "ab497e4b-b706-4ae7-be49-228979a95eb4" ,
132+ ]
126133 apply_common_args (args , server = self .connect_server , key = self .api_key )
127134 result = runner .invoke (cli , args )
128135 self .assertEqual (result .exit_code , 0 , result .output )
@@ -136,9 +143,14 @@ def test_content_describe(self):
136143 def test_content_download_bundle (self ):
137144 register_uris (self .connect_server )
138145 runner = CliRunner ()
139- args = ["content" , "download-bundle" ,
140- "-g" , "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
141- "-o" , f"{ TEMP_DIR } /bundle.tar.gz" ]
146+ args = [
147+ "content" ,
148+ "download-bundle" ,
149+ "-g" ,
150+ "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
151+ "-o" ,
152+ f"{ TEMP_DIR } /bundle.tar.gz" ,
153+ ]
142154 apply_common_args (args , server = self .connect_server , key = self .api_key )
143155 result = runner .invoke (cli , args )
144156 self .assertEqual (result .exit_code , 0 , result .output )
@@ -156,9 +168,7 @@ def test_build(self):
156168 apply_common_args (args , server = self .connect_server , key = self .api_key )
157169 result = runner .invoke (cli , args )
158170 self .assertEqual (result .exit_code , 0 , result .output )
159- self .assertTrue (
160- os .path .exists ("%s/%s.json" % (TEMP_DIR , _normalize_server_url (self .connect_server )))
161- )
171+ self .assertTrue (os .path .exists ("%s/%s.json" % (TEMP_DIR , _normalize_server_url (self .connect_server ))))
162172
163173 # list the "tracked" content
164174 args = ["content" , "build" , "ls" , "-g" , "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ]
@@ -192,16 +202,21 @@ def test_build_retry(self):
192202 runner = CliRunner ()
193203
194204 # add 3 content items
195- args = ["content" , "build" , "add" ,
196- "-g" , "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
197- "-g" , "ab497e4b-b706-4ae7-be49-228979a95eb4" ,
198- "-g" , "cdfed1f7-0e09-40eb-996d-0ef77ea2d797" ]
205+ args = [
206+ "content" ,
207+ "build" ,
208+ "add" ,
209+ "-g" ,
210+ "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
211+ "-g" ,
212+ "ab497e4b-b706-4ae7-be49-228979a95eb4" ,
213+ "-g" ,
214+ "cdfed1f7-0e09-40eb-996d-0ef77ea2d797" ,
215+ ]
199216 apply_common_args (args , server = self .connect_server , key = self .api_key )
200217 result = runner .invoke (cli , args )
201218 self .assertEqual (result .exit_code , 0 , result .output )
202- self .assertTrue (
203- os .path .exists ("%s/%s.json" % (TEMP_DIR , _normalize_server_url (self .connect_server )))
204- )
219+ self .assertTrue (os .path .exists ("%s/%s.json" % (TEMP_DIR , _normalize_server_url (self .connect_server ))))
205220
206221 # change the content build status so it looks like it was interrupted/failed
207222 store = ContentBuildStore (RSConnectServer (self .connect_server , self .api_key ))
@@ -216,10 +231,17 @@ def test_build_retry(self):
216231 self .assertEqual (result .exit_code , 0 , result .output )
217232
218233 # check that the build succeeded
219- args = ["content" , "build" , "ls" ,
220- "-g" , "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
221- "-g" , "ab497e4b-b706-4ae7-be49-228979a95eb4" ,
222- "-g" , "cdfed1f7-0e09-40eb-996d-0ef77ea2d797" ]
234+ args = [
235+ "content" ,
236+ "build" ,
237+ "ls" ,
238+ "-g" ,
239+ "7d59c5c7-c4a7-4950-acc3-3943b7192bc4" ,
240+ "-g" ,
241+ "ab497e4b-b706-4ae7-be49-228979a95eb4" ,
242+ "-g" ,
243+ "cdfed1f7-0e09-40eb-996d-0ef77ea2d797" ,
244+ ]
223245 apply_common_args (args , server = self .connect_server , key = self .api_key )
224246 result = runner .invoke (cli , args )
225247 self .assertEqual (result .exit_code , 0 , result .output )
0 commit comments