Skip to content

Commit

Permalink
skip bucket notifications integration tests if capabilities are missi…
Browse files Browse the repository at this point in the history
…ng in the key
  • Loading branch information
mjurbanski-reef committed May 8, 2024
1 parent 8c39a0e commit 4a06596
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion test/integration/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
def test_bucket_notification_rules(bucket):
import pytest


def test_bucket_notification_rules(bucket, b2_api):
if 'writeBucketNotifications' not in b2_api.account_info.get_allowed()['capabilities']:
pytest.skip('Test account does not have writeBucketNotifications capability')

assert bucket.set_notification_rules([]) == []
assert bucket.get_notification_rules() == []

Expand Down
11 changes: 9 additions & 2 deletions test/integration/test_raw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,15 @@ def raw_api_test_helper(raw_api, should_cleanup_old_buckets):
# b2_authorize_account
print('b2_authorize_account')
auth_dict = authorize_raw_api(raw_api)
missing_capabilities = set(ALL_CAPABILITIES) - {'readBuckets', 'listAllBucketNames'
} - set(auth_dict['allowed']['capabilities'])

preview_feature_caps = {
'readBucketNotifications',
'writeBucketNotifications',
}
missing_capabilities = (
set(ALL_CAPABILITIES) - {'readBuckets', 'listAllBucketNames'} - preview_feature_caps -
set(auth_dict['allowed']['capabilities'])
)
assert not missing_capabilities, 'it appears that the raw_api integration test is being run with a non-full key. Missing capabilities: {}'.format(
missing_capabilities,
)
Expand Down

0 comments on commit 4a06596

Please sign in to comment.