Skip to content

Commit c386fcd

Browse files
committed
black formatted
1 parent 94a53f2 commit c386fcd

File tree

8 files changed

+242
-84
lines changed

8 files changed

+242
-84
lines changed

cloudshell/sandbox_rest/exceptions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class SandboxRestException(Exception):
5-
""" Base Exception Class inside Rest client class """
5+
"""Base Exception Class inside Rest client class"""
66

77
def __init__(self, msg: str, response: Response = None):
88
self.msg = msg
@@ -11,7 +11,9 @@ def __init__(self, msg: str, response: Response = None):
1111
def __str__(self):
1212
return self._format_err_msg(self.msg, self.response)
1313

14-
def _format_err_msg(self, custom_err_msg="Failed Api Call", response: Response = None) -> str:
14+
def _format_err_msg(
15+
self, custom_err_msg="Failed Api Call", response: Response = None
16+
) -> str:
1517
err_msg = f"Sandbox API Error: {custom_err_msg}"
1618

1719
if response:
@@ -27,6 +29,6 @@ def _format_response_msg(response: Response):
2729

2830

2931
class SandboxRestAuthException(SandboxRestException):
30-
""" Failed auth action """
32+
"""Failed auth action"""
3133

3234
pass

cloudshell/sandbox_rest/sandbox_api.py

Lines changed: 200 additions & 68 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def lines_from_file(file_name: str) -> List[str]:
2626
packages=find_packages(),
2727
version=read_file("version.txt"),
2828
long_description=read_file("README.MD"),
29-
long_description_content_type='text/markdown',
29+
long_description_content_type="text/markdown",
3030
install_requires=lines_from_file("requirements.txt"),
3131
test_requires=lines_from_file("test-requirements.txt"),
3232
classifiers=[

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
@pytest.fixture(scope="session")
1111
def admin_session() -> SandboxRestApiSession:
1212
with SandboxRestApiSession(
13-
host=CLOUDSHELL_SERVER, username=CLOUDSHELL_ADMIN_USER, password=CLOUDSHELL_ADMIN_PASSWORD, domain=CLOUDSHELL_DOMAIN
13+
host=CLOUDSHELL_SERVER,
14+
username=CLOUDSHELL_ADMIN_USER,
15+
password=CLOUDSHELL_ADMIN_PASSWORD,
16+
domain=CLOUDSHELL_DOMAIN,
1417
) as api:
1518
yield api
1619
time.sleep(2)

tests/test_api _no_sandbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_get_default_blueprint(admin_session: SandboxRestApiSession):
2727

2828

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

tests/test_api_empty_sandbox.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def blueprint_id(admin_session: SandboxRestApiSession, empty_blueprint):
2020
@pytest.fixture(scope="module")
2121
def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
2222
# start sandbox
23-
start_res = admin_session.start_sandbox(blueprint_id=blueprint_id, sandbox_name="Pytest empty blueprint test")
23+
start_res = admin_session.start_sandbox(
24+
blueprint_id=blueprint_id, sandbox_name="Pytest empty blueprint test"
25+
)
2426
sandbox_id = start_res["id"]
2527
print(f"Sandbox started: {sandbox_id}")
2628
yield sandbox_id
@@ -42,7 +44,9 @@ def setup_execution_id(admin_session: SandboxRestApiSession, sandbox_id: str):
4244
counter += 1
4345

4446
print("Rerunning Setup...")
45-
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND)
47+
res = admin_session.run_sandbox_command(
48+
sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND
49+
)
4650
assert type(res) is dict
4751
print("Setup re-run execution response")
4852
pretty_print_response(res)
@@ -73,8 +77,13 @@ def test_get_sandbox_commands(admin_session, sandbox_id):
7377
commands_res = admin_session.get_sandbox_commands(sandbox_id)
7478
assert type(commands_res) is list
7579
print(f"Sandbox commands: {[x['name'] for x in commands_res]}")
76-
first_sb_command = admin_session.get_sandbox_command_details(sandbox_id, commands_res[0]["name"])
77-
print(f"SB command name: {first_sb_command['name']}\n" f"description: {first_sb_command['description']}")
80+
first_sb_command = admin_session.get_sandbox_command_details(
81+
sandbox_id, commands_res[0]["name"]
82+
)
83+
print(
84+
f"SB command name: {first_sb_command['name']}\n"
85+
f"description: {first_sb_command['description']}"
86+
)
7887

7988

8089
def test_get_sandbox_events(admin_session, sandbox_id):

tests/test_api_heath_check_sandbox.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def blueprint_id(admin_session: SandboxRestApiSession, dut_blueprint):
2323
@pytest.fixture(scope="module")
2424
def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
2525
# start sandbox
26-
start_res = admin_session.start_sandbox(blueprint_id=blueprint_id, sandbox_name="Pytest DUT blueprint test")
26+
start_res = admin_session.start_sandbox(
27+
blueprint_id=blueprint_id, sandbox_name="Pytest DUT blueprint test"
28+
)
2729
sandbox_id = start_res["id"]
2830
print(f"Sandbox started: {sandbox_id}")
2931
yield sandbox_id
@@ -32,17 +34,23 @@ def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
3234

3335

3436
@pytest.fixture(scope="module")
35-
def component_id(admin_session: SandboxRestApiSession, sandbox_id: str, dut_blueprint: str):
37+
def component_id(
38+
admin_session: SandboxRestApiSession, sandbox_id: str, dut_blueprint: str
39+
):
3640
components = admin_session.get_sandbox_components(sandbox_id)
3741
component_filter = [x for x in components if x["component_type"] == DUT_MODEL]
3842
assert component_filter
3943
return component_filter[0]["id"]
4044

4145

4246
@pytest.fixture(scope="module")
43-
def execution_id(admin_session: SandboxRestApiSession, sandbox_id: str, component_id: str):
47+
def execution_id(
48+
admin_session: SandboxRestApiSession, sandbox_id: str, component_id: str
49+
):
4450
print("Starting DUT Command...")
45-
res = admin_session.run_component_command(sandbox_id=sandbox_id, component_id=component_id, command_name=DUT_COMMAND)
51+
res = admin_session.run_component_command(
52+
sandbox_id=sandbox_id, component_id=component_id, command_name=DUT_COMMAND
53+
)
4654
assert type(res) is dict
4755
print("Started execution response")
4856
pretty_print_response(res)

tests/test_rerun_setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
@pytest.fixture(scope="module")
1414
def sandbox_id(admin_session: SandboxRestApiSession, empty_blueprint):
1515
# start sandbox
16-
start_res = admin_session.start_sandbox(blueprint_id=empty_blueprint, sandbox_name="Pytest empty blueprint test")
16+
start_res = admin_session.start_sandbox(
17+
blueprint_id=empty_blueprint, sandbox_name="Pytest empty blueprint test"
18+
)
1719
sandbox_id = start_res["id"]
1820
print(f"Sandbox started: {sandbox_id}")
1921
yield sandbox_id
@@ -35,7 +37,9 @@ def setup_execution_id(admin_session: SandboxRestApiSession, sandbox_id: str):
3537
counter += 1
3638

3739
print("Rerunning Setup...")
38-
res = admin_session.run_sandbox_command(sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND)
40+
res = admin_session.run_sandbox_command(
41+
sandbox_id=sandbox_id, command_name=BLUEPRINT_SETUP_COMMAND
42+
)
3943
assert type(res) is dict
4044
print("Setup re-run execution response")
4145
pretty_print_response(res)

0 commit comments

Comments
 (0)