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

Fix an issue calling incorrect api #253

Merged
merged 1 commit into from
May 31, 2021
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Refactored `FileVersionInfo` to `FileVersion`
* `ScanPoliciesManager` exclusion interface changed

### Fixed
* Fix call to incorrect internal api in `B2Api.get_download_url_for_file_name`

## [1.8.0] - 2021-05-21

### Added
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def get_download_url_for_file_name(self, bucket_name, file_name):
:param str bucket_name: a bucket name
:param str file_name: a file name
"""
self.check_bucket_restrictions(bucket_name)
self.check_bucket_name_restrictions(bucket_name)
return '%s/file/%s/%s' % (
self.account_info.get_download_url(), bucket_name, b2_url_encode(file_name)
)
Expand Down
14 changes: 14 additions & 0 deletions test/unit/v_all/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ def test_get_bucket_by_id_v2(self):
self.cache.save_bucket(Bucket(api=self.api, name='bucket_name', id_='bucket_id'))
read_bucket = self.api.get_bucket_by_id('bucket_id')
assert read_bucket.name == 'bucket_name'

def test_get_download_url_for_file_name(self):
self._authorize_account()

download_url = self.api.get_download_url_for_file_name('bucket1', 'some-file.txt')

assert download_url == 'http://download.example.com/file/bucket1/some-file.txt'

def test_get_download_url_for_fileid(self):
self._authorize_account()

download_url = self.api.get_download_url_for_fileid('file-id')

assert download_url == 'http://download.example.com/b2api/v2/b2_download_file_by_id?fileId=file-id'