From 1f1627fe386df1dfded6944a2aed52fa981c31f2 Mon Sep 17 00:00:00 2001 From: Maciej Lech Date: Thu, 12 Dec 2024 19:26:43 +0100 Subject: [PATCH] Upgrade SDK to fix integration tests --- changelog.d/+fix_test_sync_for_win.fixed.md | 1 + pdm.lock | 8 ++++---- pyproject.toml | 2 +- test/integration/conftest.py | 8 +++++++- test/integration/test_b2_command_line.py | 19 ++++++------------- 5 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 changelog.d/+fix_test_sync_for_win.fixed.md diff --git a/changelog.d/+fix_test_sync_for_win.fixed.md b/changelog.d/+fix_test_sync_for_win.fixed.md new file mode 100644 index 00000000..23b9cd2f --- /dev/null +++ b/changelog.d/+fix_test_sync_for_win.fixed.md @@ -0,0 +1 @@ +Update to b2sdk 2.7.0 to fix integration tests on Windows. diff --git a/pdm.lock b/pdm.lock index 50487521..553625d7 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "bundle", "doc", "format", "full", "license", "lint", "release", "test"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:a280055f603cde69f5a2733cd5424bc8e7429427ca2a240f5c3181aabe36bbcf" +content_hash = "sha256:4bbf1f4d9d7aae87b10f5a4f47d13e93087b6e2e350d2b0252d0208c6f903159" [[metadata.targets]] requires_python = ">=3.9" @@ -112,7 +112,7 @@ files = [ [[package]] name = "b2sdk" -version = "2.6.0" +version = "2.7.0" requires_python = ">=3.8" summary = "Backblaze B2 SDK" groups = ["default"] @@ -124,8 +124,8 @@ dependencies = [ "typing-extensions>=4.7.1; python_version < \"3.12\"", ] files = [ - {file = "b2sdk-2.6.0-py3-none-any.whl", hash = "sha256:b72e9b9dd19f3a6c8b5586b81f4dfa91dc1225610192e5c2afbbbfa1cf3f66a0"}, - {file = "b2sdk-2.6.0.tar.gz", hash = "sha256:626ef3a81989479a7b1371c8cd868c95e21cc5e0b074647443a43895325bb9e2"}, + {file = "b2sdk-2.7.0-py3-none-any.whl", hash = "sha256:9875b73e16ab5240c8544bd79d6f23c319679b1769bc64d7f5401a8b0d489fb1"}, + {file = "b2sdk-2.7.0.tar.gz", hash = "sha256:efd9a5c59dcddfe626a7860caa7f420ec4b1c50b0ad30972ccebf17392795cf9"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index b11bab87..5d1024ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ dependencies = [ "argcomplete>=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'", diff --git a/test/integration/conftest.py b/test/integration/conftest.py index bc4ef771..bd3b941f 100755 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -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 diff --git a/test/integration/test_b2_command_line.py b/test/integration/test_b2_command_line.py index c8710947..2082bc93 100755 --- a/test/integration/test_b2_command_line.py +++ b/test/integration/test_b2_command_line.py @@ -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 = { @@ -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]) @@ -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 @@ -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"] ) == []