Skip to content

Commit

Permalink
nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
nforsg committed Aug 21, 2023
1 parent df15f47 commit 3c91b43
Showing 1 changed file with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,70 @@ def test_startDockerEngine(self, grpc_stub, mocker: pytest_mock.MockFixture) ->
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.start_docker_engine', return_value=(True, "PIPE", "PIPE"))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.start_docker_engine(stub=grpc_stub)
assert response.running
assert response.running

def test_stopDockerEngine(self, grpc_stub, mocker: pytest_mock.MockFixture) -> None:
"""
Tests the stopDockerEngine grpc
:param grpc_stub: the stub for the GRPC server to make the request to
:param mocker: the mocker object to mock functions with external dependencies
:return: None
"""
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_docker_engine_running', return_value=True)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.stop_docker_engine', return_value=(False, None, None))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.stop_docker_engine(stub=grpc_stub)
assert not response.running

mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_docker_engine_running', return_value=False)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.stop_docker_engine', return_value=(True, "PIPE", "PIPE"))
response = csle_cluster.cluster_manager.query_cluster_manager.stop_docker_engine(stub=grpc_stub)
assert not response.running

def test_startNginx(self, grpc_stub, mocker: pytest_mock.MockFixture) -> None:
"""
Tests the startNginx grpc
:param grpc_stub: the stub for the GRPC server to make the request to
:param mocker: the mocker object to mock functions with external dependencies
:return: None
"""
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_nginx_running', return_value=True)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.start_nginx', return_value=(False, None, None))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.start_nginx(stub=grpc_stub)
assert response.running

mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_nginx_running', return_value=False)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.start_nginx', return_value=(True, "PIPE", "PIPE"))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.start_nginx(stub=grpc_stub)
assert response.running

def test_stopNginx(self, grpc_stub, mocker: pytest_mock.MockFixture) -> None:
"""
Tests the stopNginx grpc
:param grpc_stub: the stub for the GRPC server to make the request to
:param mocker: the mocker object to mock functions with external dependencies
:return: None
"""
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_nginx_running', return_value=True)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.stop_nginx', return_value=(False, None, None))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.stop_nginx(stub=grpc_stub)
assert not response.running

mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.is_nginx_running', return_value=False)
mocker.patch('csle_common.controllers.management_system_controller.'
'ManagementSystemController.stop_nginx', return_value=(True, "PIPE", "PIPE"))
response: ServiceStatusDTO = csle_cluster.cluster_manager.query_cluster_manager.stop_nginx(stub=grpc_stub)
assert not response.running

0 comments on commit 3c91b43

Please sign in to comment.