From 128e2227d6068dd642c66893638d48b33c2d6b0d Mon Sep 17 00:00:00 2001 From: Cristian-VM2 Date: Tue, 26 Mar 2024 12:39:11 +0000 Subject: [PATCH] #2404 add missing test and revert some name changes --- benchmark/config/benchmark_training_config.yaml | 2 +- .../results/v2.0.0/v2.0.0_benchmark_metadata.json | 2 +- .../simulator/system/applications/application.py | 2 +- .../_system/_applications/test_database_client.py | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/benchmark/config/benchmark_training_config.yaml b/benchmark/config/benchmark_training_config.yaml index 17811586..02b6377c 100644 --- a/benchmark/config/benchmark_training_config.yaml +++ b/benchmark/config/benchmark_training_config.yaml @@ -158,7 +158,7 @@ green_ier_blocked: -0.001 # Patching / Reset durations os_patching_duration: 5 # The time taken to patch the OS node_reset_duration: 5 # The time taken to reset a node (hardware) -service_fixing_duration: 5 # The time taken to patch a service +service_patching_duration: 5 # The time taken to patch a service file_system_repairing_limit: 5 # The time take to repair the file system file_system_restoring_limit: 5 # The time take to restore the file system file_system_scanning_limit: 5 # The time taken to scan the file system diff --git a/benchmark/results/v2.0.0/v2.0.0_benchmark_metadata.json b/benchmark/results/v2.0.0/v2.0.0_benchmark_metadata.json index 3ed57745..b2745967 100644 --- a/benchmark/results/v2.0.0/v2.0.0_benchmark_metadata.json +++ b/benchmark/results/v2.0.0/v2.0.0_benchmark_metadata.json @@ -5634,7 +5634,7 @@ "green_ier_blocked": -0.001, "os_patching_duration": 5, "node_reset_duration": 5, - "service_fixing_duration": 5, + "service_patching_duration": 5, "file_system_repairing_limit": 5, "file_system_restoring_limit": 5, "file_system_scanning_limit": 5 diff --git a/src/primaite/simulator/system/applications/application.py b/src/primaite/simulator/system/applications/application.py index 4ea893e0..617fdc23 100644 --- a/src/primaite/simulator/system/applications/application.py +++ b/src/primaite/simulator/system/applications/application.py @@ -117,7 +117,7 @@ class Application(IOSoftware): """The main application loop.""" pass - def close(self) -> None: + def close(self) -> bool: """Close the Application.""" if self.operating_state == ApplicationOperatingState.RUNNING: self.sys_log.info(f"Closed Application{self.name}") diff --git a/tests/unit_tests/_primaite/_simulator/_system/_applications/test_database_client.py b/tests/unit_tests/_primaite/_simulator/_system/_applications/test_database_client.py index b9b43b25..5098fcde 100644 --- a/tests/unit_tests/_primaite/_simulator/_system/_applications/test_database_client.py +++ b/tests/unit_tests/_primaite/_simulator/_system/_applications/test_database_client.py @@ -111,6 +111,19 @@ def test_query_when_client_is_closed(database_client_on_computer): assert database_client.query(sql="test") is False +def test_query_fail_to_connect(database_client_on_computer): + """Database client query should return False if the connect attempt fails.""" + database_client, computer = database_client_on_computer + + def return_false(): + return False + + database_client.connect = return_false + database_client.connected = False + + assert database_client.query(sql="test") is False + + def test_client_receives_response_when_closed(database_client_on_computer): """Database client receive should return False when it is closed.""" database_client, computer = database_client_on_computer