Esempio n. 1
0
    def test_gvfs_wrapper_bash_exception_any(self, mock_mkdir):
        """
        Test 'gvfs_wrapper' doesn't handle any BashException.
        """
        mock_mkdir.side_effect = BashException
        sync = Sync(FAKE_MTP_DETAILS, "", "")

        with self.assertRaises(BashException):
            sync.gvfs_wrapper(mock_mkdir, "/tmp/dir")
Esempio n. 2
0
    def test_gvfs_wrapper_common_exception(self, mock_mkdir):
        """
        Test 'gvfs_wrapper' isn't ignoring common exceptions.
        """
        mock_mkdir.side_effect = ValueError
        sync = Sync(FAKE_MTP_DETAILS, "", "")

        with self.assertRaises(ValueError):
            sync.gvfs_wrapper(mock_mkdir, "/tmp/dir")
Esempio n. 3
0
    def test_gvfs_wrapper_bash_exception_exact(self, mock_mount, mock_mkdir):
        """
        Test 'gvfs_wrapper' handles only a specific BashException.
        """
        mock_mkdir.side_effect = [
            BashException("Connection reset by peer"),
            None,
        ]
        sync = Sync(FAKE_MTP_DETAILS, "", "")
        sync.gvfs_wrapper(mock_mkdir, "/tmp/dir")

        self.assertEqual(mock_mkdir.call_count, 2)
        mock_mount.assert_called_once_with(sync.mtp_url)