Skip to content

Commit

Permalink
tests: update range tests to handle zero ranges
Browse files Browse the repository at this point in the history
closes #652

Signed-off-by: Evgeniy Zayats <zayatsevgeniy@nspcc.io>
  • Loading branch information
Evgeniy Zayats committed Feb 27, 2025
1 parent 6868b8d commit 563c575
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pytest_tests/tests/object/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,28 @@ def test_object_get_range_hash(
f"Expected range hash to match {range_cut} slice of file payload"
)

if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) > "0.44.2":
with allure.step("Verify zero payload ranges"):
range_hash = get_range_hash(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="0:0",
)
assert get_file_hash(file_path) == range_hash, "Expected range hash to match full file payload"

with pytest.raises(Exception, match=r".*zero length with non-zero offset.*"):
get_range_hash(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="5:0",
)

@allure.title("Validate native object API get_range")
def test_object_get_range(self, request: FixtureRequest, storage_objects: list[StorageObjectInfo], max_object_size):
"""
Expand Down Expand Up @@ -594,6 +616,30 @@ def test_object_get_range(self, request: FixtureRequest, storage_objects: list[S
== range_content
), f"Expected range content to match {range_cut} slice of file payload"

if self.neofs_env.get_binary_version(self.neofs_env.neofs_node_path) > "0.44.2":
with allure.step("Verify zero payload ranges"):
_, range_content = get_range(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="0:0",
)
assert get_file_content(file_path, mode="rb") == range_content, (
"Expected range content to match full file payload"
)

with pytest.raises(Exception, match=r".*zero length with non-zero offset.*"):
get_range(
wallet,
cid,
oid,
shell=self.shell,
endpoint=self.neofs_env.sn_rpc,
range_cut="5:0",
)

@allure.title("Validate native object API get_range for a complex object")
def test_object_get_range_complex(self, default_wallet: NodeWallet, container: str, complex_object_size: int):
"""
Expand Down

0 comments on commit 563c575

Please sign in to comment.