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
810import pytest
9- from common import *
10- from constants import *
1111
1212from cloudshell .sandbox_rest .sandbox_api import SandboxRestApiSession
1313
1414
1515@pytest .fixture (scope = "module" )
1616def 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"\n Sandbox ended: { sandbox_id } " )
@@ -34,40 +34,42 @@ def sandbox_id(admin_session: SandboxRestApiSession, blueprint_id):
3434@pytest .fixture (scope = "module" )
3535def 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" )
4444def 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" )
5658def 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
6365def 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" )
0 commit comments