Skip to content

Commit

Permalink
lib: use random values for ranges, closes nspcc-dev#632
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Zayats <zayatsevgeniy@nspcc.io>
  • Loading branch information
Evgeniy Zayats authored and evgeniiz321 committed Sep 25, 2023
1 parent af5aa53 commit 320a6eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions robot/resources/lib/python_keywords/object_access.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import random
from typing import Optional

import allure
Expand Down Expand Up @@ -142,6 +143,13 @@ def can_get_head_object(
return True


def _generate_random_range_cut(offset: int = 0, height: int = 10):
# [X:0] requests are not allowed
offset = random.randint(offset, height-1)
height = height - random.randint(offset, height-1)
return f"{offset}:{height}"


def can_get_range_of_object(
wallet: str,
cid: str,
Expand All @@ -159,7 +167,7 @@ def can_get_range_of_object(
cid,
oid,
bearer=bearer,
range_cut="0:10",
range_cut=_generate_random_range_cut(),
wallet_config=wallet_config,
xhdr=xhdr,
shell=shell,
Expand Down Expand Up @@ -190,7 +198,7 @@ def can_get_range_hash_of_object(
cid,
oid,
bearer=bearer,
range_cut="0:10",
range_cut=_generate_random_range_cut(),
wallet_config=wallet_config,
xhdr=xhdr,
shell=shell,
Expand Down

0 comments on commit 320a6eb

Please sign in to comment.