Skip to content

Commit ea56813

Browse files
committed
black reformatted
1 parent 29998c6 commit ea56813

File tree

7 files changed

+40
-52
lines changed

7 files changed

+40
-52
lines changed

cloudshell/sandbox_rest/sandbox_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ def delete_execution(self, execution_id: str) -> None:
403403
raise SandboxRestException(f"Failed to delete execution for '{execution_id}'", response)
404404
response_dict = response.json()
405405
if not response_dict["result"] == "success":
406-
raise SandboxRestException(f"Failed execution deletion of id {execution_id}\n"
407-
f"Response: {response_dict}")
406+
raise SandboxRestException(f"Failed execution deletion of id {execution_id}\n" f"Response: {response_dict}")
408407

409408

410409
if __name__ == "__main__":

tests/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
23
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
34

45

@@ -9,4 +10,4 @@ def pretty_print_response(dict_response):
910

1011
def get_blueprint_id_from_name(api: SandboxRestApiSession, bp_name: str):
1112
res = api.get_blueprint_details(bp_name)
12-
return res["id"]
13+
return res["id"]

tests/conftest.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import time
22

33
import pytest
4-
from env_settings import *
54
from constants import *
5+
from env_settings import *
66

77
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
88

99

1010
@pytest.fixture(scope="session")
1111
def admin_session() -> SandboxRestApiSession:
12-
with SandboxRestApiSession(host=CLOUDSHELL_SERVER,
13-
username=CLOUDSHELL_ADMIN_USER,
14-
password=CLOUDSHELL_ADMIN_PASSWORD,
15-
domain=CLOUDSHELL_DOMAIN) as api:
12+
with SandboxRestApiSession(
13+
host=CLOUDSHELL_SERVER, username=CLOUDSHELL_ADMIN_USER, password=CLOUDSHELL_ADMIN_PASSWORD, domain=CLOUDSHELL_DOMAIN
14+
) as api:
1615
yield api
1716
time.sleep(2)
1817
print("admin session token revoked")
@@ -26,5 +25,3 @@ def empty_blueprint():
2625
@pytest.fixture(scope="session")
2726
def dut_blueprint():
2827
return DUT_BLUEPRINT
29-
30-

tests/test_api _no_sandbox.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99

1010
def test_get_sandboxes(admin_session: SandboxRestApiSession):
1111
res = admin_session.get_sandboxes()
12-
assert(type(res) is list)
12+
assert type(res) is list
1313
print(f"Sandbox count found in system: {len(res)}")
1414

1515

1616
def test_get_blueprints(admin_session: SandboxRestApiSession):
1717
bp_res = admin_session.get_blueprints()
18-
assert(type(bp_res) is list)
18+
assert type(bp_res) is list
1919
print(f"Blueprint count found in system: '{len(bp_res)}'")
2020

2121

2222
def test_get_default_blueprint(admin_session: SandboxRestApiSession):
2323
bp_res = admin_session.get_blueprint_details(DEFAULT_EMPTY_BLUEPRINT)
24-
assert(type(bp_res) is dict)
24+
assert type(bp_res) is dict
2525
bp_name = bp_res["name"]
2626
print(f"Pulled details for '{bp_name}'")
2727

2828

2929
def test_get_and_delete_token(admin_session: SandboxRestApiSession):
3030
""" get token for admin user """
3131
token_res = admin_session.get_token_for_target_user("admin")
32-
assert(type(token_res) is str)
32+
assert type(token_res) is str
3333
print(f"Token response: '{token_res}'")

tests/test_api_empty_sandbox.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44
import time
55

66
import pytest
7-
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
8-
from constants import *
97
from common import *
8+
from constants import *
9+
10+
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
1011

1112

1213
@pytest.fixture(scope="module")
1314
def blueprint_id(admin_session: SandboxRestApiSession, empty_blueprint):
1415
res_id = get_blueprint_id_from_name(admin_session, empty_blueprint)
15-
assert(type(res_id) is str)
16+
assert type(res_id) is str
1617
return res_id
1718

1819

1920
@pytest.fixture(scope="module")
2021
def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
2122
# start sandbox
22-
start_res = admin_session.start_sandbox(
23-
blueprint_id=blueprint_id, sandbox_name="Pytest empty blueprint test"
24-
)
23+
start_res = admin_session.start_sandbox(blueprint_id=blueprint_id, sandbox_name="Pytest empty blueprint test")
2524
sandbox_id = start_res["id"]
2625
print(f"Sandbox started: {sandbox_id}")
2726
yield sandbox_id
@@ -43,63 +42,62 @@ def setup_execution_id(admin_session: SandboxRestApiSession, sandbox_id: str):
4342
counter += 1
4443

4544
print("Rerunning Setup...")
46-
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id,
47-
command_name=BLUEPRINT_SETUP_COMMAND)
48-
assert (type(res) is dict)
45+
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND)
46+
assert type(res) is dict
4947
print("Setup re-run execution response")
5048
pretty_print_response(res)
5149
execution_id = res["executionId"]
5250
return execution_id
5351

5452

5553
def test_start_stop(admin_session, sandbox_id):
56-
assert (type(sandbox_id) is str)
54+
assert type(sandbox_id) is str
5755
print(f"Sandbox ID: {sandbox_id}")
5856

5957

6058
def test_get_sandbox_details(admin_session, sandbox_id):
6159
details_res = admin_session.get_sandbox_details(sandbox_id)
62-
assert (type(details_res) is dict)
60+
assert type(details_res) is dict
6361
sb_name = details_res["name"]
6462
print(f"Pulled details for sandbox '{sb_name}'")
6563

6664

6765
def test_get_components(admin_session, sandbox_id):
6866
components_res = admin_session.get_sandbox_components(sandbox_id)
69-
assert (type(components_res) is list)
67+
assert type(components_res) is list
7068
component_count = len(components_res)
7169
print(f"component count found: {component_count}")
7270

7371

7472
def test_get_sandbox_commands(admin_session, sandbox_id):
7573
commands_res = admin_session.get_sandbox_commands(sandbox_id)
76-
assert (type(commands_res) is list)
74+
assert type(commands_res) is list
7775
print(f"Sandbox commands: {[x['name'] for x in commands_res]}")
7876
first_sb_command = admin_session.get_sandbox_command_details(sandbox_id, commands_res[0]["name"])
7977
print(f"SB command name: {first_sb_command['name']}\n" f"description: {first_sb_command['description']}")
8078

8179

8280
def test_get_sandbox_events(admin_session, sandbox_id):
8381
activity_res = admin_session.get_sandbox_activity(sandbox_id)
84-
assert (type(activity_res) is dict and "events" in activity_res)
82+
assert type(activity_res) is dict and "events" in activity_res
8583
events = activity_res["events"]
8684
print(f"activity events count: {len(events)}")
8785

8886

8987
def test_get_console_output(admin_session, sandbox_id):
9088
output_res = admin_session.get_sandbox_output(sandbox_id)
91-
assert (type(output_res) is dict and "entries" in output_res)
89+
assert type(output_res) is dict and "entries" in output_res
9290
entries = output_res["entries"]
9391
print(f"Sandbox output entries count: {len(entries)}")
9492

9593

9694
def test_get_instructions(admin_session, sandbox_id):
9795
instructions_res = admin_session.get_sandbox_instructions(sandbox_id)
98-
assert (type(instructions_res) is str)
96+
assert type(instructions_res) is str
9997
print(f"Pulled sandbox instructions: '{instructions_res}'")
10098

10199

102100
def test_extend_sandbox(admin_session, sandbox_id):
103101
extend_response = admin_session.extend_sandbox(sandbox_id, "PT0H10M")
104-
assert (type(extend_response) is dict and "remaining_time" in extend_response)
102+
assert type(extend_response) is dict and "remaining_time" in extend_response
105103
print(f"extended sandbox. Remaining time: {extend_response['remaining_time']}")

tests/test_api_heath_check_sandbox.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@
77
import time
88

99
import pytest
10-
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
11-
from constants import *
1210
from common import *
11+
from constants import *
12+
13+
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
1314

1415

1516
@pytest.fixture(scope="module")
1617
def blueprint_id(admin_session: SandboxRestApiSession, dut_blueprint):
1718
res_id = get_blueprint_id_from_name(admin_session, dut_blueprint)
18-
assert(type(res_id) is str)
19+
assert type(res_id) is str
1920
return res_id
2021

2122

2223
@pytest.fixture(scope="module")
2324
def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
2425
# start sandbox
25-
start_res = admin_session.start_sandbox(
26-
blueprint_id=blueprint_id, sandbox_name="Pytest DUT blueprint test"
27-
)
26+
start_res = admin_session.start_sandbox(blueprint_id=blueprint_id, sandbox_name="Pytest DUT blueprint test")
2827
sandbox_id = start_res["id"]
2928
print(f"Sandbox started: {sandbox_id}")
3029
yield sandbox_id
@@ -43,10 +42,8 @@ def component_id(admin_session: SandboxRestApiSession, sandbox_id: str, dut_blue
4342
@pytest.fixture(scope="module")
4443
def execution_id(admin_session: SandboxRestApiSession, sandbox_id: str, component_id: str):
4544
print("Starting DUT Command...")
46-
res = admin_session.run_component_command(sandbox_id=sandbox_id,
47-
component_id=component_id,
48-
command_name=DUT_COMMAND)
49-
assert(type(res) is dict)
45+
res = admin_session.run_component_command(sandbox_id=sandbox_id, component_id=component_id, command_name=DUT_COMMAND)
46+
assert type(res) is dict
5047
print("Started execution response")
5148
pretty_print_response(res)
5249
execution_id = res["executionId"]
@@ -56,7 +53,7 @@ def execution_id(admin_session: SandboxRestApiSession, sandbox_id: str, componen
5653
@pytest.fixture(scope="module")
5754
def test_get_execution_details(admin_session, execution_id):
5855
res = admin_session.get_execution_details(execution_id)
59-
assert(type(res) is dict)
56+
assert type(res) is dict
6057
print("Execution Details")
6158
pretty_print_response(res)
6259

@@ -66,5 +63,3 @@ def test_delete_execution(admin_session, execution_id, test_get_execution_detail
6663
time.sleep(1)
6764
admin_session.delete_execution(execution_id)
6865
print("Execution deleted")
69-
70-

tests/test_rerun_setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
import time
55

66
import pytest
7-
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
8-
from constants import *
97
from common import *
8+
from constants import *
9+
10+
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
1011

1112

1213
@pytest.fixture(scope="module")
1314
def sandbox_id(admin_session: SandboxRestApiSession, empty_blueprint):
1415
# start sandbox
15-
start_res = admin_session.start_sandbox(
16-
blueprint_id=empty_blueprint, sandbox_name="Pytest empty blueprint test"
17-
)
16+
start_res = admin_session.start_sandbox(blueprint_id=empty_blueprint, sandbox_name="Pytest empty blueprint test")
1817
sandbox_id = start_res["id"]
1918
print(f"Sandbox started: {sandbox_id}")
2019
yield sandbox_id
@@ -36,9 +35,8 @@ def setup_execution_id(admin_session: SandboxRestApiSession, sandbox_id: str):
3635
counter += 1
3736

3837
print("Rerunning Setup...")
39-
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id,
40-
command_name=BLUEPRINT_SETUP_COMMAND)
41-
assert (type(res) is dict)
38+
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND)
39+
assert type(res) is dict
4240
print("Setup re-run execution response")
4341
pretty_print_response(res)
4442
execution_id = res["executionId"]

0 commit comments

Comments
 (0)