From 680dbca574cfcaccbd9cbb662b8d7e0033712fb2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 11 May 2022 07:56:15 -0400 Subject: [PATCH] UT: Use only Python3.7 features in test_aws_command_runner --- .../services/aws/test_aws_command_runner.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/aws/test_aws_command_runner.py b/monkey/tests/unit_tests/monkey_island/cc/services/aws/test_aws_command_runner.py index f04932b93..1076e3a4d 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/aws/test_aws_command_runner.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/aws/test_aws_command_runner.py @@ -149,45 +149,40 @@ def test_correct_instance_id(successful_mock_client): start_infection_monkey_agent(successful_mock_client, INSTANCE_ID, "linux", ISLAND_IP) successful_mock_client.send_command.assert_called_once() - assert successful_mock_client.send_command.call_args.kwargs["InstanceIds"] == [INSTANCE_ID] + call_args_kwargs = successful_mock_client.send_command.call_args[1] + assert call_args_kwargs["InstanceIds"] == [INSTANCE_ID] def test_linux_doc_name(successful_mock_client): start_infection_monkey_agent(successful_mock_client, INSTANCE_ID, "linux", ISLAND_IP) successful_mock_client.send_command.assert_called_once() - assert ( - successful_mock_client.send_command.call_args.kwargs["DocumentName"] == LINUX_DOCUMENT_NAME - ) + call_args_kwargs = successful_mock_client.send_command.call_args[1] + assert call_args_kwargs["DocumentName"] == LINUX_DOCUMENT_NAME def test_windows_doc_name(successful_mock_client): start_infection_monkey_agent(successful_mock_client, INSTANCE_ID, "windows", ISLAND_IP) successful_mock_client.send_command.assert_called_once() - assert ( - successful_mock_client.send_command.call_args.kwargs["DocumentName"] - == WINDOWS_DOCUMENT_NAME - ) + call_args_kwargs = successful_mock_client.send_command.call_args[1] + assert call_args_kwargs["DocumentName"] == WINDOWS_DOCUMENT_NAME def test_linux_command(successful_mock_client): start_infection_monkey_agent(successful_mock_client, INSTANCE_ID, "linux", ISLAND_IP) successful_mock_client.send_command.assert_called_once() - assert ( - "wget" in successful_mock_client.send_command.call_args.kwargs["Parameters"]["commands"][0] - ) + call_args_kwargs = successful_mock_client.send_command.call_args[1] + assert "wget" in call_args_kwargs["Parameters"]["commands"][0] def test_windows_command(successful_mock_client): start_infection_monkey_agent(successful_mock_client, INSTANCE_ID, "windows", ISLAND_IP) successful_mock_client.send_command.assert_called_once() - assert ( - "DownloadFile" - in successful_mock_client.send_command.call_args.kwargs["Parameters"]["commands"][0] - ) + call_args_kwargs = successful_mock_client.send_command.call_args[1] + assert "DownloadFile" in call_args_kwargs["Parameters"]["commands"][0] def test_multiple_status_queries(send_command_response, in_progress_response, success_response):