Skip to content

Commit 121f05c

Browse files
authored
integration tests (#605)
1 parent f788344 commit 121f05c

File tree

3 files changed

+260
-1
lines changed

3 files changed

+260
-1
lines changed

tests/integration/conftest.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def linode_with_label():
217217
)
218218

219219
yield result
220-
221220
res_arr = result.split(",")
222221
linode_id = res_arr[4]
223222
delete_target_id(target="linodes", id=linode_id)
@@ -450,3 +449,41 @@ def pytest_configure(config):
450449
config.addinivalue_line(
451450
"markers", "smoke: mark test as part of smoke test suite"
452451
)
452+
453+
454+
@pytest.fixture
455+
def created_linode_id():
456+
timestamp = str(time.time_ns())
457+
label = "cli" + timestamp
458+
result = (
459+
exec_test_command(
460+
LINODE_BASE_CMD
461+
+ [
462+
"create",
463+
"--type",
464+
"g6-nanode-1",
465+
"--region",
466+
"us-ord",
467+
"--image",
468+
DEFAULT_TEST_IMAGE,
469+
"--label",
470+
label,
471+
"--root_pass",
472+
DEFAULT_RANDOM_PASS,
473+
"--text",
474+
"--delimiter",
475+
",",
476+
"--no-headers",
477+
"--format",
478+
"label,region,type,image,id",
479+
"--no-defaults",
480+
]
481+
)
482+
.stdout.decode()
483+
.rstrip()
484+
)
485+
486+
res_arr = result.split(",")
487+
linode_id = res_arr[4]
488+
yield linode_id
489+
delete_target_id(target="linodes", id=linode_id)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import pytest
2+
3+
from tests.integration.helpers import assert_headers_in_lines, exec_test_command
4+
5+
BASE_CMD = ["linode-cli", "tickets"]
6+
7+
8+
# this will create a support ticket on your account
9+
@pytest.mark.skip(reason="this will create a support ticket")
10+
def test_create_support_ticket(created_linode_id):
11+
linode_id = created_linode_id
12+
exec_test_command(
13+
BASE_CMD
14+
+ [
15+
"create",
16+
"--description",
17+
"Creating support ticket for test verification",
18+
"--linode_id",
19+
linode_id,
20+
"--summary",
21+
"Testing ticket" "--text",
22+
"--no-headers",
23+
]
24+
)
25+
26+
27+
def test_tickets_list():
28+
res = (
29+
exec_test_command(BASE_CMD + ["list", "--text", "--delimiter=,"])
30+
.stdout.decode()
31+
.rstrip()
32+
)
33+
lines = res.splitlines()
34+
headers = ["summary", "opened_by", "opened"]
35+
assert_headers_in_lines(headers, lines)
36+
37+
38+
@pytest.fixture
39+
def tickets_id():
40+
ticket_ids = (
41+
exec_test_command(
42+
BASE_CMD
43+
+ [
44+
"list",
45+
"--text",
46+
"--no-headers",
47+
"--delimiter",
48+
",",
49+
"--format",
50+
"id",
51+
]
52+
)
53+
.stdout.decode()
54+
.rstrip()
55+
.split(",")
56+
)
57+
first_id = ticket_ids[0]
58+
yield first_id
59+
60+
61+
def test_tickets_view(tickets_id):
62+
ticket_id = tickets_id
63+
res = (
64+
exec_test_command(
65+
BASE_CMD + ["view", ticket_id, "--text", "--delimiter=,"]
66+
)
67+
.stdout.decode()
68+
.rstrip()
69+
)
70+
lines = res.splitlines()
71+
headers = ["summary", "opened_by", "opened"]
72+
assert_headers_in_lines(headers, lines)
73+
74+
75+
@pytest.mark.skip(
76+
reason="Creation of tickets are skipped no way of currently testing this"
77+
)
78+
def test_reply_support_ticket(tickets_id):
79+
ticket_id = tickets_id
80+
exec_test_command(
81+
BASE_CMD
82+
+ [
83+
"reply",
84+
ticket_id,
85+
"--description",
86+
"test reply on the support ticket",
87+
"--text",
88+
"--no-headers",
89+
]
90+
)
91+
92+
93+
def test_view_replies_support_ticket(tickets_id):
94+
ticket_id = tickets_id
95+
res = (
96+
exec_test_command(
97+
BASE_CMD + ["replies", ticket_id, "--text", "--delimiter=,"]
98+
)
99+
.stdout.decode()
100+
.rstrip()
101+
)
102+
lines = res.splitlines()
103+
headers = ["created_by", "created"]
104+
assert_headers_in_lines(headers, lines)
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import pytest
2+
3+
from tests.integration.helpers import assert_headers_in_lines, exec_test_command
4+
5+
BASE_CMD = ["linode-cli", "profile"]
6+
7+
8+
def test_profile_view():
9+
res = (
10+
exec_test_command(BASE_CMD + ["view", "--text", "--delimiter=,"])
11+
.stdout.decode()
12+
.rstrip()
13+
)
14+
lines = res.splitlines()
15+
headers = ["username", "email", "restricted"]
16+
assert_headers_in_lines(headers, lines)
17+
18+
19+
def test_profile_apps_list():
20+
res = (
21+
exec_test_command(BASE_CMD + ["apps-list", "--text", "--delimiter=,"])
22+
.stdout.decode()
23+
.rstrip()
24+
)
25+
lines = res.splitlines()
26+
headers = ["label", "scopes", "website"]
27+
assert_headers_in_lines(headers, lines)
28+
29+
30+
def test_profile_devices_list():
31+
res = (
32+
exec_test_command(
33+
BASE_CMD + ["devices-list", "--text", "--delimiter=,"]
34+
)
35+
.stdout.decode()
36+
.rstrip()
37+
)
38+
lines = res.splitlines()
39+
headers = ["created", "expiry", "user_agent"]
40+
assert_headers_in_lines(headers, lines)
41+
42+
43+
@pytest.fixture
44+
def login_ids():
45+
login_id = (
46+
exec_test_command(
47+
BASE_CMD
48+
+ [
49+
"logins-list",
50+
"--text",
51+
"--no-headers",
52+
"--delimiter",
53+
",",
54+
"--format",
55+
"id",
56+
]
57+
)
58+
.stdout.decode()
59+
.rstrip()
60+
.splitlines()
61+
)
62+
first_login_id = login_id[0]
63+
yield first_login_id
64+
65+
66+
def test_profile_login_list():
67+
res = (
68+
exec_test_command(BASE_CMD + ["logins-list", "--text", "--delimiter=,"])
69+
.stdout.decode()
70+
.rstrip()
71+
)
72+
lines = res.splitlines()
73+
headers = ["datetime", "username", "status"]
74+
assert_headers_in_lines(headers, lines)
75+
76+
77+
def test_profile_login_view(login_ids):
78+
login_id = login_ids
79+
res = (
80+
exec_test_command(
81+
BASE_CMD + ["login-view", login_id, "--text", "--delimiter=,"]
82+
)
83+
.stdout.decode()
84+
.rstrip()
85+
)
86+
lines = res.splitlines()
87+
headers = ["datetime", "username", "status"]
88+
assert_headers_in_lines(headers, lines)
89+
90+
91+
def test_security_questions_list():
92+
res = (
93+
exec_test_command(
94+
[
95+
"linode-cli",
96+
"security-questions",
97+
"list",
98+
"--text",
99+
"--delimiter=,",
100+
]
101+
)
102+
.stdout.decode()
103+
.rstrip()
104+
)
105+
lines = res.splitlines()
106+
headers = ["security_questions.id", "security_questions.question"]
107+
assert_headers_in_lines(headers, lines)
108+
109+
110+
def test_profile_token_list():
111+
res = (
112+
exec_test_command(BASE_CMD + ["tokens-list", "--text", "--delimiter=,"])
113+
.stdout.decode()
114+
.rstrip()
115+
)
116+
lines = res.splitlines()
117+
headers = ["label", "scopes", "token"]
118+
assert_headers_in_lines(headers, lines)

0 commit comments

Comments
 (0)