Skip to content

Commit

Permalink
file hide subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
adal-chiriliuc-reef committed Apr 25, 2024
1 parent 2d31d7e commit b0e9f79
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
13 changes: 12 additions & 1 deletion b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ def _run(self, args):
return 0


class HideFile(Command):
class FileHideBase(Command):
"""
Uploads a new, hidden, version of the given file.
Expand Down Expand Up @@ -4925,6 +4925,12 @@ class FileCopyById(FileCopyByIdBase):
COMMAND_NAME = 'CopyById'


@File.subcommands_registry.register
class FileHide(FileHideBase):
__doc__ = FileHideBase.__doc__
COMMAND_NAME = 'hide'


class FileInfo2(CmdReplacedByMixin, B2URIFileArgMixin, FileInfoBase):
__doc__ = FileInfoBase.__doc__
replaced_by_cmd = (File, FileInfo)
Expand Down Expand Up @@ -4982,6 +4988,11 @@ class CopyFileById(CmdReplacedByMixin, FileCopyByIdBase):
replaced_by_cmd = (File, FileCopyById)


class HideFile(CmdReplacedByMixin, FileHideBase):
__doc__ = FileHideBase.__doc__
replaced_by_cmd = (File, FileHide)


class ConsoleTool:
"""
Implements the commands available in the B2 command-line tool
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_b2_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def test_basic(b2_tool, bucket_name, sample_file, tmp_path, b2_uri_args):
['file', 'download', '--quiet', f'b2://{bucket_name}/b/1', tmp_path / 'a']
)

b2_tool.should_succeed(['hide-file', bucket_name, 'c'])
b2_tool.should_succeed(['file', 'hide', bucket_name, 'c'])

list_of_files = b2_tool.should_succeed_json(
['ls', '--json', '--recursive', *b2_uri_args(bucket_name)]
Expand Down
4 changes: 2 additions & 2 deletions test/unit/_cli/test_autocomplete_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_complete_with_escaped_control_characters(
store=autocomplete_cache.HomeCachePickleStore(tmp_path),
)

with autocomplete_runner(f'b2 hide-file {bucket} '):
with autocomplete_runner(f'b2 file hide {bucket} '):
exit, argcomplete_output = argcomplete_result()
assert exit == 0
assert escaped_cc_file_name in argcomplete_output
Expand All @@ -200,7 +200,7 @@ def test_complete_with_file_suggestions(
tracker=autocomplete_cache.VersionTracker(),
store=autocomplete_cache.HomeCachePickleStore(tmp_path),
)
with autocomplete_runner(f'b2 hide-file {bucket} '):
with autocomplete_runner(f'b2 file hide {bucket} '):
exit, argcomplete_output = argcomplete_result()
assert exit == 0
assert file_name in argcomplete_output
Expand Down
26 changes: 13 additions & 13 deletions test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ def test_files(self):
}

self._run_command(
['hide-file', 'my-bucket', 'file1.txt'],
['file', 'hide', 'my-bucket', 'file1.txt'],
expected_json_in_stdout=expected_json,
)

Expand Down Expand Up @@ -1269,7 +1269,7 @@ def test_files_encrypted(self):
}

self._run_command(
['hide-file', 'my-bucket', 'file1.txt'],
['file', 'hide', 'my-bucket', 'file1.txt'],
expected_json_in_stdout=expected_json,
)

Expand Down Expand Up @@ -1982,10 +1982,10 @@ def test_get_bucket_with_hidden(self):
# something has failed if the output of 'bucket get' does not match the canon.
stdout, stderr = self._get_stdouterr()
console_tool = self.console_tool_class(stdout, stderr)
console_tool.run_command(['b2', 'hide-file', 'my-bucket', 'hidden1'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', 'hidden2'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', 'hidden3'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', 'hidden4'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', 'hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', 'hidden2'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', 'hidden3'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', 'hidden4'])

# Now check the output of `bucket get` against the canon.
expected_json = {
Expand Down Expand Up @@ -2043,13 +2043,13 @@ def test_get_bucket_complex(self):
# something has failed if the output of 'bucket get' does not match the canon.
stdout, stderr = self._get_stdouterr()
console_tool = self.console_tool_class(stdout, stderr)
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/hidden2'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'hide-file', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden2'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/2/hidden3'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/2/hidden3'])

# Now check the output of `bucket get` against the canon.
expected_json = {
Expand Down

0 comments on commit b0e9f79

Please sign in to comment.