Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated SyncReport Methods #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed
* Remove `Bucket.copy_file` and `Bucket.start_large_file`
* Remove deprecated `SyncReport` methods

## [1.7.0] - 2021-04-22

Expand Down
24 changes: 0 additions & 24 deletions b2sdk/sync/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,30 +251,6 @@ def local_permission_error(self, path):
def symlink_skipped(self, path):
pass

@property
def local_file_count(self):
# TODO: Deprecated. Should be removed in v2
return self.total_count

@local_file_count.setter
def local_file_count(self, value):
# TODO: Deprecated. Should be removed in v2
self.total_count = value

@property
def local_done(self):
# TODO: Deprecated. Should be removed in v2
return self.total_done

@local_done.setter
def local_done(self, value):
# TODO: Deprecated. Should be removed in v2
self.total_done = value

# TODO: Deprecated. Should be removed in v2
update_local = update_total
end_local = end_total


class SyncFileReporter(AbstractProgressListener):
"""
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
from b2sdk.v1.cache import AbstractCache
from b2sdk.v1.sync import (
ScanPoliciesManager, DEFAULT_SCAN_MANAGER, zip_folders, Synchronizer, AbstractFolder,
LocalFolder, B2Folder, parse_sync_folder
LocalFolder, B2Folder, parse_sync_folder, SyncReport
)
from b2sdk.v1.api import B2Api
1 change: 1 addition & 0 deletions b2sdk/v1/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

from .folder import *
from .folder_parser import *
from .report import *
from .scan_policies import *
from .sync import *
33 changes: 33 additions & 0 deletions b2sdk/v1/sync/report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
######################################################################
#
# File: b2sdk/v1/sync/report.py
#
# Copyright 2021 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################

from b2sdk import _v2 as v2


# override to retain legacy methods
class SyncReport(v2.SyncReport):
@property
def local_file_count(self):
return self.total_count

@local_file_count.setter
def local_file_count(self, value):
self.total_count = value

@property
def local_done(self):
return self.total_done

@local_done.setter
def local_done(self, value):
self.total_done = value

update_local = v2.SyncReport.update_total
end_local = v2.SyncReport.end_total
54 changes: 54 additions & 0 deletions test/unit/sync/test_sync_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
######################################################################
#
# File: test/unit/sync/test_sync_report.py
#
# Copyright 2019 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################

from unittest.mock import MagicMock

import pytest

from apiver_deps import SyncReport


class TestSyncReport:
def test_bad_terminal(self):
stdout = MagicMock()
stdout.write = MagicMock(
side_effect=[
UnicodeEncodeError('codec', u'foo', 100, 105, 'artificial UnicodeEncodeError')
] + list(range(25))
)
sync_report = SyncReport(stdout, False)
sync_report.print_completion('transferred: 123.txt')

@pytest.mark.apiver(to_ver=1)
def test_legacy_methods(self):
stdout = MagicMock()
sync_report = SyncReport(stdout, False)

assert not sync_report.total_done
assert not sync_report.local_done
assert 0 == sync_report.total_count
assert 0 == sync_report.local_file_count

sync_report.local_done = True
assert sync_report.local_done
assert sync_report.total_done

sync_report.local_file_count = 8
assert 8 == sync_report.local_file_count
assert 8 == sync_report.total_count

sync_report.update_local(7)
assert 15 == sync_report.total_count
assert 15 == sync_report.local_file_count

sync_report = SyncReport(stdout, False)
assert not sync_report.total_done
sync_report.end_local()
assert sync_report.total_done
27 changes: 0 additions & 27 deletions test/unit/v0/test_sync_report.py

This file was deleted.

27 changes: 0 additions & 27 deletions test/unit/v1/test_sync_report.py

This file was deleted.