def TestCheckurlMultiFiveUrls(self):
     urllist = [{
         'url': "Url1",
         'size': 512,
         'filename': "Filename1"
     }, {
         'url': "Url2",
         'filename': "Filename2"
     }, {
         'url': "Url3",
         'size': 1024
     }, {
         'url': "Url4",
         'size': 134789,
         'filename': "Filename4"
     }, {
         'url': "Url5",
         'filename': "Filename5"
     }]
     self.remote.checkurl.return_value = urllist
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     self.remote.checkurl.assert_called_once_with("Url")
     self.assertEqual(
         utils.second_buffer_line(self.output),
         "CHECKURL-MULTI Url1 512 Filename1 Url2 UNKNOWN Filename2 Url3 1024  Url4 134789 Filename4 Url5 UNKNOWN Filename5"
     )
 def TestRenameexportFailure(self):
     self.remote.renameexport.side_effect = RemoteError()
     self.annex.Listen(io.StringIO("EXPORT Name\nRENAMEEXPORT Key NewName"))
     self.remote.renameexport.assert_called_once_with(
         "Key", "Name", "NewName")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "RENAMEEXPORT-FAILURE Key")
 def TestTransferexportRetrieveSuccess(self):
     self.annex.Listen(
         io.StringIO("EXPORT Name\nTRANSFEREXPORT RETRIEVE Key File"))
     self.remote.transferexport_retrieve.assert_called_once_with(
         "Key", "File", "Name")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "TRANSFER-SUCCESS RETRIEVE Key")
示例#4
0
 def TestTransferRetrieveFailure(self):
     self.remote.transfer_retrieve.side_effect = RemoteError("ErrorMsg")
     self.annex.Listen(io.StringIO("TRANSFER RETRIEVE Key File"))
     self.remote.transfer_retrieve.assert_called_once_with("Key", "File")
     self.assertEqual(
         utils.second_buffer_line(self.output),
         "TRANSFER-FAILURE RETRIEVE Key ErrorMsg",
     )
 def TestTransferexportStoreFailure(self):
     self.remote.transferexport_store.side_effect = RemoteError("ErrorMsg")
     self.annex.Listen(
         io.StringIO("EXPORT Name\nTRANSFEREXPORT STORE Key File"))
     self.remote.transferexport_store.assert_called_once_with(
         "Key", "File", "Name")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "TRANSFER-FAILURE STORE Key ErrorMsg")
 def TestCheckurlContents(self):
     self.remote.checkurl.return_value = [{
         'size': 512,
         'filename': "Filename"
     }]
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     self.remote.checkurl.assert_called_once_with("Url")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "CHECKURL-CONTENTS 512 Filename")
 def TestCheckurlMultiOneItemWithUrl(self):
     self.remote.checkurl.return_value = [{
         'url': "Url_exact",
         'size': 512,
         'filename': "Filename"
     }]
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     self.remote.checkurl.assert_called_once_with("Url")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "CHECKURL-MULTI Url_exact 512 Filename")
 def TestCheckurlMultiTabInUrlAndFilename(self):
     urllist = [{
         'url': "Url\twith\ttabs",
         'size': 512,
         'filename': "Filename1"
     }, {
         'url': "Url2",
         'filename': "Filename\twith\ttabs"
     }]
     self.remote.checkurl.return_value = urllist
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     result = "CHECKURL-MULTI Url\twith\ttabs 512 Filename1 Url2 UNKNOWN Filename\twith\ttabs"
     self.assertEqual(utils.second_buffer_line(self.output), result)
示例#9
0
 def TestCheckurlMultiTwoUrls(self):
     urllist = [
         {
             "url": "Url1",
             "size": 512,
             "filename": "Filename1"
         },
         {
             "url": "Url2",
             "filename": "Filename2"
         },
     ]
     self.remote.checkurl.return_value = urllist
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     self.remote.checkurl.assert_called_once_with("Url")
     self.assertEqual(
         utils.second_buffer_line(self.output),
         "CHECKURL-MULTI Url1 512 Filename1 Url2 UNKNOWN Filename2",
     )
 def TestCheckurlUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("CHECKURL Url"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestWhereisUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("WHEREIS Key"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestGetcostUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("GETCOST"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestGetavailabilityUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("GETAVAILABILITY"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestRenameexportSuccess(self):
     self.annex.Listen(io.StringIO("EXPORT Name\nRENAMEEXPORT Key NewName"))
     self.remote.renameexport.assert_called_once_with(
         "Key", "Name", "NewName")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "RENAMEEXPORT-SUCCESS Key")
 def TestWhereisFailure(self):
     self.remote.whereis.return_value = False
     self.annex.Listen(io.StringIO("WHEREIS Key"))
     self.remote.whereis.assert_called_once_with("Key")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "WHEREIS-FAILURE")
 def TestRemoveexportdirectorySuccess(self):
     self.annex.Listen(io.StringIO("REMOVEEXPORTDIRECTORY Directory"))
     self.remote.removeexportdirectory.assert_called_once_with("Directory")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "REMOVEEXPORTDIRECTORY-SUCCESS")
 def TestRemoveexportdirectoryFailure(self):
     self.remote.removeexportdirectory.side_effect = RemoteError()
     self.annex.Listen(io.StringIO("REMOVEEXPORTDIRECTORY Directory"))
     self.remote.removeexportdirectory.assert_called_once_with("Directory")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "REMOVEEXPORTDIRECTORY-FAILURE")
 def TestListconfigsEmpty(self):
     self.annex.Listen(io.StringIO("LISTCONFIGS"))
     self.assertEqual(utils.second_buffer_line(self.output), "CONFIGEND")
 def TestPrepareSuccess(self):
     self.annex.Listen(io.StringIO("PREPARE"))
     self.remote.prepare.call_count == 1
     self.assertEqual(utils.second_buffer_line(self.output),
                      "PREPARE-SUCCESS")
 def TestRemoveexportdirectoryUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("REMOVEEXPORTDIRECTORY Directory"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestTransferexportRetrieveUnsupportedRequest(self):
     self.annex.Listen(
         io.StringIO("EXPORT Name\nTRANSFEREXPORT RETRIEVE Key File"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestPrepareFailure(self):
     self.remote.prepare.side_effect = RemoteError("ErrorMsg")
     self.annex.Listen(io.StringIO("PREPARE"))
     self.remote.prepare.call_count == 1
     self.assertEqual(utils.second_buffer_line(self.output),
                      "PREPARE-FAILURE ErrorMsg")
 def TestExportsupportedSuccess(self):
     self.annex.Listen(io.StringIO("EXPORTSUPPORTED"))
     self.remote.exportsupported.call_count == 1
     self.assertEqual(utils.second_buffer_line(self.output),
                      "EXPORTSUPPORTED-SUCCESS")
 def TestExportsupportedFailure(self):
     self.remote.exportsupported.return_value = False
     self.annex.Listen(io.StringIO("EXPORTSUPPORTED"))
     self.remote.exportsupported.call_count == 1
     self.assertEqual(utils.second_buffer_line(self.output),
                      "EXPORTSUPPORTED-FAILURE")
 def TestCheckpresentexportUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("EXPORT Name\nCHECKPRESENTEXPORT Key"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestTransferStoreSuccess(self):
     self.annex.Listen(io.StringIO("TRANSFER STORE Key File"))
     self.remote.transfer_store.assert_called_once_with("Key", "File")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "TRANSFER-SUCCESS STORE Key")
 def TestRenameexportUnsupportedRequest(self):
     self.annex.Listen(io.StringIO("EXPORT Name\nRENAMEEXPORT Key NewName"))
     self.assertEqual(utils.second_buffer_line(self.output),
                      "UNSUPPORTED-REQUEST")
 def TestCheckpresentexportFailure(self):
     self.remote.checkpresentexport.return_value = False
     self.annex.Listen(io.StringIO("EXPORT Name\nCHECKPRESENTEXPORT Key"))
     self.remote.checkpresentexport.assert_called_once_with("Key", "Name")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "CHECKPRESENT-FAILURE Key")
 def TestCheckpresentSuccess(self):
     self.remote.checkpresent.return_value = True
     self.annex.Listen(io.StringIO("CHECKPRESENT Key"))
     self.remote.checkpresent.assert_called_once_with("Key")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "CHECKPRESENT-SUCCESS Key")
 def TestCheckpresentexportUnknown(self):
     self.remote.checkpresentexport.side_effect = RemoteError("ErrorMsg")
     self.annex.Listen(io.StringIO("EXPORT Name\nCHECKPRESENTEXPORT Key"))
     self.remote.checkpresentexport.assert_called_once_with("Key", "Name")
     self.assertEqual(utils.second_buffer_line(self.output),
                      "CHECKPRESENT-UNKNOWN Key ErrorMsg")