Skip to content

Commit

Permalink
add file copy-by-id subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
adal-chiriliuc-reef committed Apr 25, 2024
1 parent e7ff9f6 commit 66685c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def _run(self, args):
return 0


class CopyFileById(
class FileCopyByIdBase(
HeaderFlagsMixin, DestinationSseMixin, SourceSseMixin, FileRetentionSettingMixin,
LegalHoldMixin, Command
):
Expand Down Expand Up @@ -4918,6 +4918,13 @@ class FileDownload(B2URIFileArgMixin, FileDownloadBase):
COMMAND_NAME = 'download'


@File.subcommands_registry.register
class FileCopyById(FileCopyByIdBase):
__doc__ = FileCopyByIdBase.__doc__
# TODO we can't use 'copy-by-id', gets transformed to 'copy--by--id'
COMMAND_NAME = 'CopyById'


class FileInfo2(CmdReplacedByMixin, B2URIFileArgMixin, FileInfoBase):
__doc__ = FileInfoBase.__doc__
replaced_by_cmd = (File, FileInfo)
Expand Down Expand Up @@ -4970,6 +4977,11 @@ class DownloadFileByName(CmdReplacedByMixin, B2URIBucketNFilenameArgMixin, FileD
replaced_by_cmd = (File, FileDownload)


class CopyFileById(CmdReplacedByMixin, FileCopyByIdBase):
__doc__ = FileCopyByIdBase.__doc__
replaced_by_cmd = (File, FileCopyById)


class ConsoleTool:
"""
Implements the commands available in the B2 command-line tool
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
EncryptionSetting,
)

from b2._internal.console_tool import CopyFileById
from b2._internal.console_tool import FileCopyById

from .test_base import TestBase

Expand All @@ -29,7 +29,7 @@ def test_determine_source_metadata(self):
mock_api = mock.MagicMock()
mock_console_tool = mock.MagicMock()
mock_console_tool.api = mock_api
copy_file_command = CopyFileById(mock_console_tool)
copy_file_command = FileCopyById(mock_console_tool)

result = copy_file_command._determine_source_metadata(
'id',
Expand Down

0 comments on commit 66685c2

Please sign in to comment.