Skip to content

Commit

Permalink
Merge pull request #1060 from Backblaze/fix-win-integr-test
Browse files Browse the repository at this point in the history
Fix test_sync_up for windows
  • Loading branch information
mlech-reef authored Dec 17, 2024
2 parents f0b58cb + dece212 commit ee02547
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions changelog.d/+fix_test_sync_for_win.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update to b2sdk 2.7.0 to fix integration tests on Windows.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
dependencies = [
"argcomplete>=3.5.2,<4",
"arrow>=1.0.2,<2.0.0",
"b2sdk>=2.6.0,<3",
"b2sdk>=2.7.0,<3",
"docutils>=0.18.1",
"idna~=3.4; platform_system == 'Java'",
"importlib-metadata>=3.3; python_version < '3.8'",
Expand Down
8 changes: 7 additions & 1 deletion test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,14 @@ def auto_change_account_info_dir(monkeysession) -> str:
monkeysession.delenv('B2_APPLICATION_KEY_ID', raising=False)
monkeysession.delenv('B2_APPLICATION_KEY', raising=False)

# Ignore occasional PermissionError on Windows
if sys.platform == 'win32' and (sys.version_info.major, sys.version_info.minor) > (3, 9):
kwargs = dict(ignore_cleanup_errors=True)
else:
kwargs = {}

# make b2sdk use temp dir for storing default & per-profile account information
with TemporaryDirectory() as temp_dir:
with TemporaryDirectory(**kwargs) as temp_dir:
monkeysession.setenv(B2_ACCOUNT_INFO_ENV_VAR, path.join(temp_dir, '.b2_account_info'))
monkeysession.setenv(XDG_CONFIG_HOME_ENV_VAR, temp_dir)
yield temp_dir
Expand Down
19 changes: 6 additions & 13 deletions test/integration/test_b2_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3429,10 +3429,8 @@ def test_notification_rules(b2_tool, bucket_name):
if 'writeBucketNotifications' not in auth_dict['allowed']['capabilities']:
pytest.skip('Test account does not have writeBucketNotifications capability')

private_preview_pattern = re.compile(r'FeaturePreviewWarning')
assert b2_tool.should_succeed_json(
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"],
expected_stderr_pattern=private_preview_pattern
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"]
) == []

notification_rule = {
Expand Down Expand Up @@ -3461,8 +3459,7 @@ def test_notification_rules(b2_tool, bucket_name):
"https://example.com/webhook",
"--event-type",
"b2:ObjectCreated:*",
],
expected_stderr_pattern=private_preview_pattern
]
)
expected_rules = [{**notification_rule, "isSuspended": False, "suspensionReason": ""}]
assert_dict_equal_ignore_extra(created_rule, expected_rules[0])
Expand All @@ -3480,8 +3477,7 @@ def test_notification_rules(b2_tool, bucket_name):
"--disable",
"--sign-secret",
secret,
],
expected_stderr_pattern=private_preview_pattern
]
)
expected_rules[0].update({"objectNamePrefix": "prefix", "isEnabled": False})
expected_rules[0]["targetConfiguration"]["hmacSha256SigningSecret"] = secret
Expand All @@ -3490,18 +3486,15 @@ def test_notification_rules(b2_tool, bucket_name):
# read updated rules
assert_dict_equal_ignore_extra(
b2_tool.should_succeed_json(
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"],
expected_stderr_pattern=private_preview_pattern
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"]
),
expected_rules,
)

# delete rule by name
assert b2_tool.should_succeed(
["bucket", "notification-rule", "delete", f"b2://{bucket_name}", "test-rule"],
expected_stderr_pattern=private_preview_pattern
["bucket", "notification-rule", "delete", f"b2://{bucket_name}", "test-rule"]
) == f"Rule 'test-rule' has been deleted from b2://{bucket_name}/\n"
assert b2_tool.should_succeed_json(
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"],
expected_stderr_pattern=private_preview_pattern
["bucket", "notification-rule", "list", f"b2://{bucket_name}", "--json"]
) == []

0 comments on commit ee02547

Please sign in to comment.