From 2479b8e4c7e0a79627fd321abf4ea13035d2448c Mon Sep 17 00:00:00 2001 From: Limmen Date: Fri, 12 Jul 2024 17:57:06 +0200 Subject: [PATCH] fix mocks in rest_api tests --- .../csle-rest-api/tests/test_resources_emulation_traces.py | 2 +- .../tests/test_resources_emulations_executions.py | 4 +++- .../libs/csle-rest-api/tests/test_resources_users.py | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/simulation-system/libs/csle-rest-api/tests/test_resources_emulation_traces.py b/simulation-system/libs/csle-rest-api/tests/test_resources_emulation_traces.py index d836ac27f..9bdc78e75 100644 --- a/simulation-system/libs/csle-rest-api/tests/test_resources_emulation_traces.py +++ b/simulation-system/libs/csle-rest-api/tests/test_resources_emulation_traces.py @@ -309,7 +309,7 @@ def test_emulation_traces_ids_delete(self, mocker: pytest_mock.MockFixture, flas :param list_em_trac: the list_em_trac fixture :param remove: the remove fixture """ - mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.list_emulation_traces_ids", + mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.get_emulation_trace", side_effect=get_em_tr) mocker.patch("csle_rest_api.util.rest_api_util.check_if_user_is_authorized", side_effect=not_logged_in) mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.remove_emulation_trace", diff --git a/simulation-system/libs/csle-rest-api/tests/test_resources_emulations_executions.py b/simulation-system/libs/csle-rest-api/tests/test_resources_emulations_executions.py index a79683a75..4b97e0923 100644 --- a/simulation-system/libs/csle-rest-api/tests/test_resources_emulations_executions.py +++ b/simulation-system/libs/csle-rest-api/tests/test_resources_emulations_executions.py @@ -2168,7 +2168,7 @@ def test_emulation_execution_ids_c_prod_post(self, mocker: pytest_mock.MockFixtu def test_emulation_execution_ids_dcm_post(self, mocker: pytest_mock.MockFixture, flask_app, not_logged_in, logged_in, logged_in_as_admin, get_em_ex, - merged_info, start_dcm, stop_dcm) -> None: + merged_info, start_dcm, stop_dcm, config) -> None: """ Testing the HTTPS GET method for the /emulation-executions/id/docker-stats-manager resource @@ -2182,9 +2182,11 @@ def test_emulation_execution_ids_dcm_post(self, mocker: pytest_mock.MockFixture, :param get_ex_exec: the get_ex_exec fixture :param start_dcm: the start_dcm fixture :param stop_dcm: the stop_dcm fixture + :param config: the config fixture :return: None """ mocker.patch('time.sleep', return_value=None) + mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.get_config", side_effect=config) mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.get_emulation_execution", side_effect=get_em_ex) mocker.patch("csle_cluster.cluster_manager.cluster_controller.ClusterController.get_merged_execution_info", diff --git a/simulation-system/libs/csle-rest-api/tests/test_resources_users.py b/simulation-system/libs/csle-rest-api/tests/test_resources_users.py index 31bcc9f28..4e432f735 100644 --- a/simulation-system/libs/csle-rest-api/tests/test_resources_users.py +++ b/simulation-system/libs/csle-rest-api/tests/test_resources_users.py @@ -325,7 +325,7 @@ def test_users_id_get(self, flask_app, mocker: pytest_mock.MockFixture, manageme assert response.status_code == constants.HTTPS.UNAUTHORIZED_STATUS_CODE def test_users_id_put(self, flask_app, mocker: pytest_mock.MockFixture, management_users, not_logged_in, - logged_in, authorized, unauthorized, management_config) -> None: + logged_in, authorized, unauthorized, management_config, update) -> None: """ Testing the PUT HTTPS method for the /users/id resource @@ -338,9 +338,12 @@ def test_users_id_put(self, flask_app, mocker: pytest_mock.MockFixture, manageme :param remove: the remove fixture :param logged_in: the logged_in fixture :param authorized: the athourized fixture - :param unauthorized: the unathourized fixture + :param unauthorized: the unauthorized fixture + :param update: the update fixture :return: None """ + mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.update_management_user", + side_effect=update) mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.list_management_users", side_effect=management_users) mocker.patch("csle_common.metastore.metastore_facade.MetastoreFacade.get_management_user_config",