@@ -49,14 +49,6 @@ def test_repr_returns_url_property_value(self, mocker):
4949
5050 assert PAPath ("path" ).__repr__ () == mock_url
5151
52- def test_make_sharing_url_contains_pa_site_address (self , mocker ):
53- mock_urljoin = mocker .patch ("pythonanywhere.files.urljoin" )
54- pa_path = PAPath ("path" )
55-
56- pa_path ._make_sharing_url ("rest" )
57-
58- assert mock_urljoin .call_args == call (pa_path .api .base_url .split ("api" )[0 ], "rest" )
59-
6052 def test_sanitizes_path (self ):
6153 pa_path = PAPath ("~" )
6254
@@ -205,15 +197,14 @@ class TestPAPathShare():
205197 def test_returns_full_url_for_shared_file (self , mocker ):
206198 mock_sharing_get = mocker .patch ("pythonanywhere_core.files.Files.sharing_get" )
207199 mock_sharing_get .return_value = "url"
208- mock_make_url = mocker .patch ("pythonanywhere.files.PAPath._make_sharing_url" )
209200 mock_snake = mocker .patch ("pythonanywhere.files.snakesay" )
210201 mock_info = mocker .patch ("pythonanywhere.files.logger.info" )
211202 query_path = "/pa/path/to/a/file"
212203
213204 result = PAPath (query_path ).get_sharing_url ()
214205
215206 assert mock_sharing_get .call_args == call (query_path )
216- assert mock_snake .call_args == call (f"{ query_path } is shared at { mock_make_url .return_value } " )
207+ assert mock_snake .call_args == call (f"{ query_path } is shared at { mock_sharing_get .return_value } " )
217208 assert mock_info .call_args == call (mock_snake .return_value )
218209 assert result .endswith ("url" )
219210
@@ -233,35 +224,29 @@ def test_returns_empty_string_when_file_not_shared(self, mocker):
233224
234225 def test_path_already_shared (self , mocker ):
235226 mock_sharing_post = mocker .patch ("pythonanywhere_core.files.Files.sharing_post" )
236- mock_sharing_post .return_value = (200 , "url" )
237- mock_make_url = mocker .patch ("pythonanywhere.files.PAPath._make_sharing_url" )
227+ mock_sharing_post .return_value = ("was already shared" , "url" )
238228 mock_snake = mocker .patch ("pythonanywhere.files.snakesay" )
239229 mock_info = mocker .patch ("pythonanywhere.files.logger.info" )
240230 path_to_share = "/pa/path/to/a/file"
241231
242232 result = PAPath (path_to_share ).share ()
243233
244234 assert mock_sharing_post .call_args == call (path_to_share )
245- assert mock_snake .call_args == call (f"{ path_to_share } was already shared at { mock_make_url .return_value } " )
235+ assert mock_snake .call_args == call (f"{ path_to_share } was already shared at { mock_sharing_post .return_value [ 1 ] } " )
246236 assert mock_info .call_args == call (mock_snake .return_value )
247- assert mock_make_url .call_args == call ("url" )
248- assert result == mock_make_url .return_value
249237
250238 def test_path_successfully_shared (self , mocker ):
251239 mock_sharing_post = mocker .patch ("pythonanywhere_core.files.Files.sharing_post" )
252- mock_sharing_post .return_value = (201 , "url" )
253- mock_make_url = mocker .patch ("pythonanywhere.files.PAPath._make_sharing_url" )
240+ mock_sharing_post .return_value = ("successfully shared" , "url" )
254241 mock_snake = mocker .patch ("pythonanywhere.files.snakesay" )
255242 mock_info = mocker .patch ("pythonanywhere.files.logger.info" )
256243 path_to_share = "/pa/path/to/a/file"
257244
258245 result = PAPath (path_to_share ).share ()
259246
260247 assert mock_sharing_post .call_args == call (path_to_share )
261- assert mock_snake .call_args == call (f"{ path_to_share } successfully shared at { mock_make_url .return_value } " )
248+ assert mock_snake .call_args == call (f"{ path_to_share } successfully shared at { mock_sharing_post .return_value [ 1 ] } " )
262249 assert mock_info .call_args == call (mock_snake .return_value )
263- assert mock_make_url .call_args == call ("url" )
264- assert result == mock_make_url .return_value
265250
266251 def test_warns_if_share_fails (self , mocker ):
267252 mock_sharing_post = mocker .patch ("pythonanywhere_core.files.Files.sharing_post" )
0 commit comments