Skip to content

Commit

Permalink
Merge pull request #106 from yarikoptic/enh-checkurl-msg
Browse files Browse the repository at this point in the history
Allow to communicate ErrorMsg for CHECKURL-FAILURE via RemoteError exception
  • Loading branch information
yarikoptic authored Sep 16, 2024
2 parents fe03434 + 47ce3a0 commit 718fc77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions annexremote/annexremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ def do_CLAIMURL(self, url):
def do_CHECKURL(self, url):
try:
reply = self.remote.checkurl(url)
except RemoteError:
return "CHECKURL-FAILURE"
except RemoteError as e:
return "CHECKURL-FAILURE {e}".format(e=e).rstrip()
if not reply:
return "CHECKURL-FAILURE"
elif reply is True:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_GitAnnexRequestMessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ def test_CheckurlFailure(self):
self.remote.checkurl.assert_called_once_with("Url")
self.assertEqual(utils.second_buffer_line(self.output), "CHECKURL-FAILURE")

def test_CheckurlFailureErrorMsg(self):
self.remote.checkurl.side_effect = RemoteError("ErrorMsg")
self.annex.Listen(io.StringIO("CHECKURL Url"))
self.remote.checkurl.assert_called_once_with("Url")
self.assertEqual(
utils.second_buffer_line(self.output), "CHECKURL-FAILURE ErrorMsg"
)

def test_CheckurlFailureByException(self):
self.remote.checkurl.return_value = False
self.annex.Listen(io.StringIO("CHECKURL Url"))
Expand Down

0 comments on commit 718fc77

Please sign in to comment.