Skip to content

Commit 760c68e

Browse files
committed
Improve and add missing tests for Private Image Sharing feature
1 parent 9cb93b2 commit 760c68e

File tree

3 files changed

+167
-156
lines changed

3 files changed

+167
-156
lines changed

tests/integration/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,6 @@ def get_random_region_with_caps(
210210

211211

212212
def assert_help_actions_list(expected_actions, help_output):
213-
output_actions = re.findall("\│\s(\S+)\s*\│", help_output)
213+
output_actions = re.findall("\│\s(\S+(?:,\s)?\S+)\s*\│", help_output)
214214
for expected_action in expected_actions:
215215
assert expected_action in output_actions

tests/integration/sharegroups/fixtures.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
from tests.integration.helpers import (
55
BASE_CMDS,
6-
exec_test_command, get_random_text,
6+
exec_test_command,
7+
get_random_text,
78
)
89

910

@@ -16,6 +17,23 @@ def get_region():
1617
yield first_id
1718

1819

20+
def wait_for_image_status(id, expected_status, timeout=180, interval=5):
21+
import time
22+
23+
current_status = exec_test_command(
24+
BASE_CMDS["images"] + ["view", id, "--text", "--no-headers", "--delimiter", ",", "--format", "status"]
25+
).splitlines()
26+
timer = 0
27+
while current_status[0] != expected_status and timer < timeout:
28+
time.sleep(interval)
29+
timer += interval
30+
current_status = exec_test_command(
31+
BASE_CMDS["images"] + ["view", id, "--text", "--no-headers", "--delimiter", ",", "--format", "status"]
32+
).splitlines()
33+
if timer >= timeout:
34+
raise TimeoutError(f"Created image did not reach status '{expected_status}' within {timeout} seconds.")
35+
36+
1937
@pytest.fixture(scope="function")
2038
def create_image_id(get_region):
2139
linode_id = exec_test_command(
@@ -30,7 +48,7 @@ def create_image_id(get_region):
3048
BASE_CMDS["images"] + ["create", "--label", "linode-cli-test-image-sharing-image", "--disk_id", disks[0],
3149
"--text", "--no-headers", "--delimiter", ",", "--format", "id"]
3250
)
33-
# TODO: wait_for_status
51+
wait_for_image_status(image_id, "available")
3452
yield linode_id, image_id
3553

3654

@@ -42,13 +60,3 @@ def create_share_group():
4260
"--format", "id,uuid"]
4361
).split(",")
4462
yield share_group[0], share_group[1]
45-
46-
47-
@pytest.fixture(scope="function")
48-
def create_token():
49-
label = get_random_text(8) + "_sharegroup_cli_test"
50-
created_token = exec_test_command(
51-
BASE_CMDS["profile"] + ["token-create", "--label", label, "--text", "--no-headers", "--delimiter", ",",
52-
"--format", "token"]
53-
)
54-
yield jwt.encode({"some": "payload"}, created_token, algorithm="HS256")

0 commit comments

Comments
 (0)