Skip to content

Commit a166098

Browse files
authored
Added tests as a part Test Coverage (#656)
1 parent 78cca71 commit a166098

File tree

4 files changed

+178
-4
lines changed

4 files changed

+178
-4
lines changed

linodecli/baked/operation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,11 @@ def __init__(
366366
if param.name not in {"apiVersion"}
367367
]
368368

369-
self.url_base, self.url_path, self.default_api_version = (
370-
self._get_api_url_components(operation, params)
371-
)
369+
(
370+
self.url_base,
371+
self.url_path,
372+
self.default_api_version,
373+
) = self._get_api_url_components(operation, params)
372374

373375
self.url = self.url_base + self.url_path
374376

tests/integration/account/test_account.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,45 @@ def test_service_transfers():
315315

316316
headers = ["token", "expiry", "is_sender"]
317317
assert_headers_in_lines(headers, lines)
318+
319+
320+
def test_maintenance_list():
321+
res = (
322+
exec_test_command(
323+
BASE_CMD + ["maintenance-list", "--text", "--delimiter=,"]
324+
)
325+
.stdout.decode()
326+
.rstrip()
327+
)
328+
lines = res.splitlines()
329+
330+
headers = ["entity.type", "entity.label"]
331+
assert_headers_in_lines(headers, lines)
332+
333+
334+
def test_notifications_list():
335+
res = (
336+
exec_test_command(
337+
BASE_CMD + ["notifications-list", "--text", "--delimiter=,"]
338+
)
339+
.stdout.decode()
340+
.rstrip()
341+
)
342+
lines = res.splitlines()
343+
344+
headers = ["label", "severity"]
345+
assert_headers_in_lines(headers, lines)
346+
347+
348+
def test_clients_list():
349+
res = (
350+
exec_test_command(
351+
BASE_CMD + ["clients-list", "--text", "--delimiter=,"]
352+
)
353+
.stdout.decode()
354+
.rstrip()
355+
)
356+
lines = res.splitlines()
357+
358+
headers = ["label", "status"]
359+
assert_headers_in_lines(headers, lines)

tests/integration/image/test_plugin_image_upload.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010

11-
from tests.integration.helpers import get_random_text
11+
from tests.integration.helpers import assert_headers_in_lines, get_random_text
1212

1313
REGION = "us-iad"
1414
BASE_CMD = ["linode-cli", "image-upload", "--region", REGION]
@@ -135,3 +135,63 @@ def test_file_upload_cloud_init(
135135
# Delete the image
136136
process = exec_test_command(["linode-cli", "images", "rm", image[0]["id"]])
137137
assert process.returncode == 0
138+
139+
140+
def test_image_list():
141+
res = (
142+
exec_test_command(
143+
["linode-cli", "images", "list", "--text", "--delimiter=,"]
144+
)
145+
.stdout.decode()
146+
.rstrip()
147+
)
148+
lines = res.splitlines()
149+
150+
headers = ["label", "description"]
151+
assert_headers_in_lines(headers, lines)
152+
153+
154+
@pytest.fixture
155+
def get_image_id():
156+
image_id = (
157+
exec_test_command(
158+
[
159+
"linode-cli",
160+
"images",
161+
"list",
162+
"--text",
163+
"--no-headers",
164+
"--delimiter",
165+
",",
166+
"--format",
167+
"id",
168+
]
169+
)
170+
.stdout.decode()
171+
.rstrip()
172+
.splitlines()
173+
)
174+
first_id = image_id[0].split(",")[0]
175+
yield first_id
176+
177+
178+
def test_image_view(get_image_id):
179+
image_id = get_image_id
180+
res = (
181+
exec_test_command(
182+
[
183+
"linode-cli",
184+
"images",
185+
"view",
186+
image_id,
187+
"--text",
188+
"--delimiter=,",
189+
]
190+
)
191+
.stdout.decode()
192+
.rstrip()
193+
)
194+
lines = res.splitlines()
195+
196+
headers = ["label", "description"]
197+
assert_headers_in_lines(headers, lines)

tests/integration/linodes/test_linodes.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from linodecli.exit_codes import ExitCodes
77
from tests.integration.helpers import (
8+
assert_headers_in_lines,
89
delete_target_id,
910
exec_failing_test_command,
1011
exec_test_command,
@@ -167,3 +168,72 @@ def test_add_tag_to_linode(setup_linodes):
167168
).stdout.decode()
168169

169170
assert unique_tag in result
171+
172+
173+
def list_disk_list(setup_linodes):
174+
linode_id = setup_linodes
175+
res = (
176+
exec_test_command(
177+
BASE_CMD
178+
+ [
179+
"disks-list",
180+
linode_id,
181+
"--text",
182+
"--delimiter=,",
183+
]
184+
)
185+
.stdout.decode()
186+
.rstrip()
187+
)
188+
lines = res.splitlines()
189+
190+
headers = ["id", "label"]
191+
assert_headers_in_lines(headers, lines)
192+
193+
194+
@pytest.fixture
195+
def get_disk_id(setup_linodes):
196+
linode_id = setup_linodes
197+
disk_id = (
198+
exec_test_command(
199+
BASE_CMD
200+
+ [
201+
"disks-list",
202+
linode_id,
203+
"--text",
204+
"--no-headers",
205+
"--delimiter",
206+
",",
207+
"--format",
208+
"id",
209+
]
210+
)
211+
.stdout.decode()
212+
.rstrip()
213+
.splitlines()
214+
)
215+
first_id = disk_id[0].split(",")[0]
216+
yield first_id
217+
218+
219+
def test_disk_view(setup_linodes, get_disk_id):
220+
linode_id = setup_linodes
221+
disk_id = get_disk_id
222+
res = (
223+
exec_test_command(
224+
BASE_CMD
225+
+ [
226+
"disk-view",
227+
linode_id,
228+
disk_id,
229+
"--text",
230+
"--delimiter=,",
231+
]
232+
)
233+
.stdout.decode()
234+
.rstrip()
235+
)
236+
lines = res.splitlines()
237+
238+
headers = ["id", "label"]
239+
assert_headers_in_lines(headers, lines)

0 commit comments

Comments
 (0)