Skip to content

Commit e0b294a

Browse files
committed
pre-commit reformat
1 parent 199c183 commit e0b294a

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

tests/constants.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
DEFAULT_EMPTY_BLUEPRINT = "CloudShell Sandbox Template"
2-
BLUEPRINT_SETUP_COMMAND = "Setup"
1+
# create these two blueprints and make them 'public' so they can be reserved
2+
DEFAULT_EMPTY_BLUEPRINT = "Empty Blueprint"
3+
4+
# this blueprint has a Putshell Resource in it
5+
# https://community.quali.com/repos/3318/put-shell-mock
6+
DUT_BLUEPRINT = "DUT Blueprint Test"
37

48
# DUT blueprint constants
59
DUT_MODEL = "Putshell"
610
DUT_COMMAND = "health_check"
7-
DUT_BLUEPRINT = "DUT Blueprint Test"
11+
12+
BLUEPRINT_SETUP_COMMAND = "Setup"

tests/test_api_dut_sandbox.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
- DUT model / command can be referenced in constants.py (Putshell / health_check)
66
- Assumed that only one DUT is in blueprint
77
"""
8+
import common
9+
import constants
810
import pytest
9-
from common import *
10-
from constants import *
1111

1212
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
1313

1414

1515
@pytest.fixture(scope="module")
1616
def blueprint_id(admin_session: SandboxRestApiSession, dut_blueprint):
17-
res_id = get_blueprint_id_from_name(admin_session, dut_blueprint)
17+
res_id = common.get_blueprint_id_from_name(admin_session, dut_blueprint)
1818
assert isinstance(res_id, str)
1919
return res_id
2020

@@ -25,7 +25,7 @@ def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
2525
start_res = admin_session.start_sandbox(blueprint_id=blueprint_id, sandbox_name="Pytest DUT blueprint test")
2626
sandbox_id = start_res["id"]
2727
print(f"Sandbox started: {sandbox_id}")
28-
fixed_sleep()
28+
common.fixed_sleep()
2929
yield sandbox_id
3030
admin_session.stop_sandbox(sandbox_id)
3131
print(f"\nSandbox ended: {sandbox_id}")
@@ -34,40 +34,42 @@ def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
3434
@pytest.fixture(scope="module")
3535
def component_id(admin_session: SandboxRestApiSession, sandbox_id: str):
3636
components = admin_session.get_sandbox_components(sandbox_id)
37-
fixed_sleep()
38-
component_filter = [x for x in components if x["component_type"] == DUT_MODEL]
37+
common.fixed_sleep()
38+
component_filter = [x for x in components if x["component_type"] == constants.DUT_MODEL]
3939
assert component_filter
4040
return component_filter[0]["id"]
4141

4242

4343
@pytest.fixture(scope="module")
4444
def execution_id(admin_session: SandboxRestApiSession, sandbox_id: str, component_id: str):
4545
print("Starting DUT Command...")
46-
res = admin_session.run_component_command(sandbox_id=sandbox_id, component_id=component_id, command_name=DUT_COMMAND)
47-
fixed_sleep()
46+
res = admin_session.run_component_command(
47+
sandbox_id=sandbox_id, component_id=component_id, command_name=constants.DUT_COMMAND
48+
)
49+
common.fixed_sleep()
4850
assert isinstance(res, dict)
4951
print("Started execution response")
50-
pretty_print_response(res)
52+
common.pretty_print_response(res)
5153
execution_id = res["executionId"]
5254
return execution_id
5355

5456

5557
@pytest.fixture(scope="module")
5658
def test_get_execution_details(admin_session, execution_id):
5759
res = admin_session.get_execution_details(execution_id)
58-
fixed_sleep()
60+
common.fixed_sleep()
5961
assert isinstance(res, dict)
6062
return res
6163

6264

6365
def test_delete_execution(admin_session, execution_id, test_get_execution_details):
6466
print("Execution Details")
65-
pretty_print_response(test_get_execution_details)
67+
common.pretty_print_response(test_get_execution_details)
6668
is_supports_cancellation = test_get_execution_details["supports_cancellation"]
6769
if not is_supports_cancellation:
6870
print("Can't cancel this command. Returning")
6971
return
7072
print("Stopping execution...")
7173
admin_session.delete_execution(execution_id)
72-
fixed_sleep()
74+
common.fixed_sleep()
7375
print("Execution deleted")

tests/test_api_empty_sandbox.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Test the api methods that require an empty, PUBLIC blueprint
33
"""
44

5+
import common
56
import pytest
6-
from common import *
77

88
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
99

1010

1111
@pytest.fixture(scope="module")
1212
def blueprint_id(admin_session: SandboxRestApiSession, empty_blueprint):
13-
res_id = get_blueprint_id_from_name(admin_session, empty_blueprint)
13+
res_id = common.get_blueprint_id_from_name(admin_session, empty_blueprint)
1414
assert isinstance(res_id, str)
1515
return res_id
1616

@@ -32,23 +32,23 @@ def test_start_stop(sandbox_id):
3232

3333

3434
def test_get_sandbox_details(admin_session, sandbox_id):
35-
random_sleep()
35+
common.random_sleep()
3636
details_res = admin_session.get_sandbox_details(sandbox_id)
3737
assert isinstance(details_res, dict)
3838
sb_name = details_res["name"]
3939
print(f"Pulled details for sandbox '{sb_name}'")
4040

4141

4242
def test_get_components(admin_session, sandbox_id):
43-
random_sleep()
43+
common.random_sleep()
4444
components_res = admin_session.get_sandbox_components(sandbox_id)
4545
assert isinstance(components_res, list)
4646
component_count = len(components_res)
4747
print(f"component count found: {component_count}")
4848

4949

5050
def test_get_sandbox_commands(admin_session, sandbox_id):
51-
random_sleep()
51+
common.random_sleep()
5252
commands_res = admin_session.get_sandbox_commands(sandbox_id)
5353
assert isinstance(commands_res, list)
5454
print(f"Sandbox commands: {[x['name'] for x in commands_res]}")
@@ -57,30 +57,30 @@ def test_get_sandbox_commands(admin_session, sandbox_id):
5757

5858

5959
def test_get_sandbox_events(admin_session, sandbox_id):
60-
random_sleep()
60+
common.random_sleep()
6161
activity_res = admin_session.get_sandbox_activity(sandbox_id)
6262
assert isinstance(activity_res, dict) and "events" in activity_res
6363
events = activity_res["events"]
6464
print(f"activity events count: {len(events)}")
6565

6666

6767
def test_get_console_output(admin_session, sandbox_id):
68-
random_sleep()
68+
common.random_sleep()
6969
output_res = admin_session.get_sandbox_output(sandbox_id)
7070
assert isinstance(output_res, dict) and "entries" in output_res
7171
entries = output_res["entries"]
7272
print(f"Sandbox output entries count: {len(entries)}")
7373

7474

7575
def test_get_instructions(admin_session, sandbox_id):
76-
random_sleep()
76+
common.random_sleep()
7777
instructions_res = admin_session.get_sandbox_instructions(sandbox_id)
7878
assert isinstance(instructions_res, str)
7979
print(f"Pulled sandbox instructions: '{instructions_res}'")
8080

8181

8282
def test_extend_sandbox(admin_session, sandbox_id):
83-
random_sleep()
83+
common.random_sleep()
8484
extend_response = admin_session.extend_sandbox(sandbox_id, "PT0H10M")
8585
assert isinstance(extend_response, dict) and "remaining_time" in extend_response
8686
print(f"extended sandbox. Remaining time: {extend_response['remaining_time']}")

tests/test_api_no_sandbox.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Test the api methods that do NOT require a blueprint
33
Live Cloudshell server is still a dependency
44
"""
5+
import common
56
import pytest
6-
from common import *
77
from constants import DEFAULT_EMPTY_BLUEPRINT
88

99
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
@@ -23,21 +23,21 @@ def test_delete_token(admin_session: SandboxRestApiSession, api_token: str):
2323

2424
def test_get_sandboxes(admin_session: SandboxRestApiSession):
2525
res = admin_session.get_sandboxes()
26-
random_sleep()
26+
common.random_sleep()
2727
assert isinstance(res, list)
2828
print(f"Sandbox count found in system: {len(res)}")
2929

3030

3131
def test_get_blueprints(admin_session: SandboxRestApiSession):
3232
bp_res = admin_session.get_blueprints()
33-
random_sleep()
33+
common.random_sleep()
3434
assert isinstance(bp_res, list)
3535
print(f"Blueprint count found in system: '{len(bp_res)}'")
3636

3737

3838
def test_get_default_blueprint(admin_session: SandboxRestApiSession):
3939
bp_res = admin_session.get_blueprint_details(DEFAULT_EMPTY_BLUEPRINT)
40-
random_sleep()
40+
common.random_sleep()
4141
assert isinstance(bp_res, dict)
4242
bp_name = bp_res["name"]
4343
print(f"Pulled details for '{bp_name}'")

0 commit comments

Comments
 (0)