Skip to content

Commit

Permalink
Fix the remaining unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
emnoor-reef committed Jan 31, 2024
1 parent 9680c69 commit b0fde01
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
6 changes: 1 addition & 5 deletions b2/_internal/b2v3/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@

# ruff: noqa: F405
from b2._internal._b2v4.registry import * # noqa
from .rm import Rm


class Ls(B2URIBucketNFolderNameArgMixin, BaseLs):
__doc__ = BaseLs.__doc__
# TODO: fix doc


class Rm(B2URIBucketNFolderNameArgMixin, BaseRm):
__doc__ = BaseRm.__doc__
# TODO: fix doc


B2.register_subcommand(AuthorizeAccount)
B2.register_subcommand(CancelAllUnfinishedLargeFiles)
B2.register_subcommand(CancelLargeFile)
Expand Down
19 changes: 19 additions & 0 deletions b2/_internal/b2v3/rm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
######################################################################
#
# File: b2/_internal/b2v3/rm.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from __future__ import annotations

from b2._internal._b2v4.registry import B2URIBucketNFolderNameArgMixin, BaseRm


# NOTE: We need to keep v3 Rm in separate file, because we need to import it in
# unit tests without registering any commands.
class Rm(B2URIBucketNFolderNameArgMixin, BaseRm):
__doc__ = BaseRm.__doc__
# TODO: fix doc
13 changes: 9 additions & 4 deletions test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
from b2sdk.v2.exception import Conflict # Any error for testing fast-fail of the rm command.
from more_itertools import one

from b2._internal._b2v4.registry import Rm as v4Rm
from b2._internal._cli.const import (
B2_APPLICATION_KEY_ENV_VAR,
B2_APPLICATION_KEY_ID_ENV_VAR,
B2_ENVIRONMENT_ENV_VAR,
)
from b2._internal.console_tool import Rm
from b2._internal.b2v3.rm import Rm as v3Rm
from b2._internal.version import VERSION

from .test_base import TestBase
Expand Down Expand Up @@ -2515,8 +2516,11 @@ class InstantReporter(ProgressReport):

@classmethod
def setUpClass(cls) -> None:
cls.original_progress_class = Rm.PROGRESS_REPORT_CLASS
Rm.PROGRESS_REPORT_CLASS = cls.InstantReporter
cls.original_v3_progress_class = v3Rm.PROGRESS_REPORT_CLASS
cls.original_v4_progress_class = v4Rm.PROGRESS_REPORT_CLASS

v3Rm.PROGRESS_REPORT_CLASS = cls.InstantReporter
v4Rm.PROGRESS_REPORT_CLASS = cls.InstantReporter

def setUp(self):
super().setUp()
Expand All @@ -2529,7 +2533,8 @@ def setUp(self):

@classmethod
def tearDownClass(cls) -> None:
Rm.PROGRESS_REPORT_CLASS = cls.original_progress_class
v3Rm.PROGRESS_REPORT_CLASS = cls.original_v3_progress_class
v4Rm.PROGRESS_REPORT_CLASS = cls.original_v4_progress_class

def test_rm_wildcard(self):
self._run_command(
Expand Down

0 comments on commit b0fde01

Please sign in to comment.