1010@pytest .fixture
1111def get_region ():
1212 regions = exec_test_command (
13- BASE_CMDS ["regions" ] + ["list" , "--text" , "--no-headers" , "--delimiter" , "," , "--format" , "id" ]
13+ BASE_CMDS ["regions" ]
14+ + [
15+ "list" ,
16+ "--text" ,
17+ "--no-headers" ,
18+ "--delimiter" ,
19+ "," ,
20+ "--format" ,
21+ "id" ,
22+ ]
1423 ).splitlines ()
1524 first_id = regions [0 ]
1625 yield first_id
@@ -20,32 +29,91 @@ def wait_for_image_status(id, expected_status, timeout=180, interval=5):
2029 import time
2130
2231 current_status = exec_test_command (
23- BASE_CMDS ["images" ] + ["view" , id , "--text" , "--no-headers" , "--delimiter" , "," , "--format" , "status" ]
32+ BASE_CMDS ["images" ]
33+ + [
34+ "view" ,
35+ id ,
36+ "--text" ,
37+ "--no-headers" ,
38+ "--delimiter" ,
39+ "," ,
40+ "--format" ,
41+ "status" ,
42+ ]
2443 ).splitlines ()
2544 timer = 0
2645 while current_status [0 ] != expected_status and timer < timeout :
2746 time .sleep (interval )
2847 timer += interval
2948 current_status = exec_test_command (
30- BASE_CMDS ["images" ] + ["view" , id , "--text" , "--no-headers" , "--delimiter" , "," , "--format" , "status" ]
49+ BASE_CMDS ["images" ]
50+ + [
51+ "view" ,
52+ id ,
53+ "--text" ,
54+ "--no-headers" ,
55+ "--delimiter" ,
56+ "," ,
57+ "--format" ,
58+ "status" ,
59+ ]
3160 ).splitlines ()
3261 if timer >= timeout :
33- raise TimeoutError (f"Created image did not reach status '{ expected_status } ' within { timeout } seconds." )
62+ raise TimeoutError (
63+ f"Created image did not reach status '{ expected_status } ' within { timeout } seconds."
64+ )
3465
3566
3667@pytest .fixture (scope = "function" )
3768def create_image_id (get_region ):
3869 linode_id = exec_test_command (
39- BASE_CMDS ["linodes" ] + ["create" , "--image" , "linode/alpine3.22" , "--region" , get_region , "--type" ,
40- "g6-nanode-1" , "--root_pass" , "aComplex@Password" , "--text" , "--no-headers" ,
41- "--delimiter" , "," , "--format" , "id" ]
70+ BASE_CMDS ["linodes" ]
71+ + [
72+ "create" ,
73+ "--image" ,
74+ "linode/alpine3.22" ,
75+ "--region" ,
76+ get_region ,
77+ "--type" ,
78+ "g6-nanode-1" ,
79+ "--root_pass" ,
80+ "aComplex@Password" ,
81+ "--text" ,
82+ "--no-headers" ,
83+ "--delimiter" ,
84+ "," ,
85+ "--format" ,
86+ "id" ,
87+ ]
4288 )
4389 disks = exec_test_command (
44- BASE_CMDS ["linodes" ] + ["disks-list" , linode_id , "--text" , "--no-headers" , "--delimiter" , "," , "--format" , "id" ]
90+ BASE_CMDS ["linodes" ]
91+ + [
92+ "disks-list" ,
93+ linode_id ,
94+ "--text" ,
95+ "--no-headers" ,
96+ "--delimiter" ,
97+ "," ,
98+ "--format" ,
99+ "id" ,
100+ ]
45101 ).splitlines ()
46102 image_id = exec_test_command (
47- BASE_CMDS ["images" ] + ["create" , "--label" , "linode-cli-test-image-sharing-image" , "--disk_id" , disks [0 ],
48- "--text" , "--no-headers" , "--delimiter" , "," , "--format" , "id" ]
103+ BASE_CMDS ["images" ]
104+ + [
105+ "create" ,
106+ "--label" ,
107+ "linode-cli-test-image-sharing-image" ,
108+ "--disk_id" ,
109+ disks [0 ],
110+ "--text" ,
111+ "--no-headers" ,
112+ "--delimiter" ,
113+ "," ,
114+ "--format" ,
115+ "id" ,
116+ ]
49117 )
50118 wait_for_image_status (image_id , "available" )
51119 yield linode_id , image_id
@@ -55,7 +123,17 @@ def create_image_id(get_region):
55123def create_share_group ():
56124 label = get_random_text (8 ) + "_sharegroup_cli_test"
57125 share_group = exec_test_command (
58- BASE_CMDS ["image-sharegroups" ] + ["create" , "--label" , label , "--text" , "--no-headers" , "--delimiter" , "," ,
59- "--format" , "id,uuid" ]
126+ BASE_CMDS ["image-sharegroups" ]
127+ + [
128+ "create" ,
129+ "--label" ,
130+ label ,
131+ "--text" ,
132+ "--no-headers" ,
133+ "--delimiter" ,
134+ "," ,
135+ "--format" ,
136+ "id,uuid" ,
137+ ]
60138 ).split ("," )
61139 yield share_group [0 ], share_group [1 ]
0 commit comments