project_name
string
class_name
string
class_modifiers
string
class_implements
int64
class_extends
int64
function_name
string
function_body
string
cyclomatic_complexity
int64
NLOC
int64
num_parameter
int64
num_token
int64
num_variable
int64
start_line
int64
end_line
int64
function_index
int64
function_params
string
function_variable
string
function_return_type
string
function_body_line_type
string
function_num_functions
int64
function_num_lines
int64
outgoing_function_count
int64
outgoing_function_names
string
incoming_function_count
int64
incoming_function_names
string
lexical_representation
string
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_with_job_id_selects_most_recent_completed_when_no_ongoing
def test_cli_job_logs_with_job_id_selects_most_recent_completed_when_no_ongoing(fresh_deadline_config,):"""Test that when there are no ongoing sessions, the most recently completed session is selected."""with patch.object(config, "get_setting") as mock_get_setting:mock_get_setting.side_effect = [MOCK_FARM_ID,# _apply_cli_options_to_config check for farm_idMOCK_QUEUE_ID,# _apply_cli_options_to_config check for queue_idMOCK_FARM_ID,# defaults.farm_idMOCK_QUEUE_ID,# defaults.queue_idMOCK_JOB_ID,# defaults.job_id]with patch("deadline.client.api.get_boto3_client") as boto3_client_mock:with patch("deadline.client.api.get_session_logs") as mock_get_logs:# Set up the paginator to return only completed sessionspaginator_mock = MagicMock()boto3_client_mock().get_paginator.return_value = paginator_mockpaginator_mock.paginate.return_value = [{"sessions": [{"sessionId": "session-completed-older","startedAt": datetime.datetime(2023, 1, 27, 6, 0, 0),"endedAt": datetime.datetime(2023, 1, 27, 7, 0, 0),# Older completion},{"sessionId": "session-completed-newer","startedAt": datetime.datetime(2023, 1, 27, 8, 0, 0),"endedAt": datetime.datetime(2023, 1, 27, 9, 0, 0),# Most recent completion},]}]# Mock the get_session_logs responsemock_get_logs.return_value = api.SessionLogResult(events=[api.LogEvent(timestamp=datetime.datetime(2023, 1, 27, 9, 0, 0),message="Most recent completed session log",ingestion_time=datetime.datetime(2023, 1, 27, 9, 0, 1),event_id="event-1",),],count=1,next_token=None,log_group=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",log_stream="session-completed-newer",)runner = CliRunner()result = runner.invoke(main,["job","logs","--job-id",MOCK_JOB_ID,],)# Verify get_session_logs was called with the most recently completed sessionmock_get_logs.assert_called_once_with(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-completed-newer",# Should select most recently ended sessionlimit=100,start_time=None,end_time=None,next_token=None,config=ANY,)# Check outputassert "Using the latest session: session-completed-newer" in result.outputassert "Most recent completed session log" in result.outputassert result.exit_code == 0
1
72
1
332
3
721
804
721
fresh_deadline_config
['runner', 'result', 'paginator_mock']
None
{"Assign": 7, "Expr": 2, "With": 3}
16
84
16
["patch.object", "patch", "patch", "MagicMock", "boto3_client_mock", "datetime.datetime", "datetime.datetime", "datetime.datetime", "datetime.datetime", "api.SessionLogResult", "api.LogEvent", "datetime.datetime", "datetime.datetime", "CliRunner", "runner.invoke", "mock_get_logs.assert_called_once_with"]
0
[]
The function (test_cli_job_logs_with_job_id_selects_most_recent_completed_when_no_ongoing) defined within the public class called public.The function start at line 721 and ends at 804. It contains 72 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 16.0 functions, and It has 16.0 functions called inside which are ["patch.object", "patch", "patch", "MagicMock", "boto3_client_mock", "datetime.datetime", "datetime.datetime", "datetime.datetime", "datetime.datetime", "api.SessionLogResult", "api.LogEvent", "datetime.datetime", "datetime.datetime", "CliRunner", "runner.invoke", "mock_get_logs.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_with_job_id_selects_most_recent_among_multiple_ongoing
def test_cli_job_logs_with_job_id_selects_most_recent_among_multiple_ongoing(fresh_deadline_config):"""Test that when there are multiple ongoing sessions, the most recently started one is selected."""with patch.object(config, "get_setting") as mock_get_setting:mock_get_setting.side_effect = [MOCK_FARM_ID,# _apply_cli_options_to_config check for farm_idMOCK_QUEUE_ID,# _apply_cli_options_to_config check for queue_idMOCK_FARM_ID,# defaults.farm_idMOCK_QUEUE_ID,# defaults.queue_idMOCK_JOB_ID,# defaults.job_id]with patch("deadline.client.api.get_boto3_client") as boto3_client_mock:with patch("deadline.client.api.get_session_logs") as mock_get_logs:# Set up the paginator to return multiple ongoing sessionspaginator_mock = MagicMock()boto3_client_mock().get_paginator.return_value = paginator_mockpaginator_mock.paginate.return_value = [{"sessions": [{"sessionId": "session-ongoing-oldest","startedAt": datetime.datetime(2023, 1, 27, 5, 0, 0),# Oldest ongoing# No endedAt - this is ongoing},{"sessionId": "session-ongoing-middle","startedAt": datetime.datetime(2023, 1, 27, 6, 0, 0),# Middle ongoing# No endedAt - this is ongoing},{"sessionId": "session-ongoing-newest","startedAt": datetime.datetime(2023, 1, 27, 7, 0, 0),# Most recent ongoing# No endedAt - this is ongoing},]}]# Mock get_job to return job nameboto3_client_mock().get_job.return_value = {"name": "Test Job Name"}# Mock the get_session_logs responsemock_get_logs.return_value = api.SessionLogResult(events=[api.LogEvent(timestamp=datetime.datetime(2023, 1, 27, 7, 0, 0),message="Most recent ongoing session log",ingestion_time=datetime.datetime(2023, 1, 27, 7, 0, 1),event_id="event-1",),],count=1,next_token=None,log_group=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",log_stream="session-ongoing-newest",)runner = CliRunner()result = runner.invoke(main,["job","logs","--job-id",MOCK_JOB_ID,],)# Verify get_job was called to get job nameboto3_client_mock().get_job.assert_called_once_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID)# Verify get_session_logs was called with the most recently started ongoing sessionmock_get_logs.assert_called_once_with(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-ongoing-newest",# Should select most recently started ongoing sessionlimit=100,start_time=None,end_time=None,next_token=None,config=ANY,)# Check output includes job informationassert "Using the latest session: session-ongoing-newest" in result.outputassert "Job ID: " + MOCK_JOB_ID in result.outputassert "Job Name: Test Job Name" in result.outputassert "Most recent ongoing session log" in result.outputassert result.exit_code == 0
1
80
1
366
3
807
905
807
fresh_deadline_config
['runner', 'result', 'paginator_mock']
None
{"Assign": 8, "Expr": 3, "With": 3}
18
99
18
["patch.object", "patch", "patch", "MagicMock", "boto3_client_mock", "datetime.datetime", "datetime.datetime", "datetime.datetime", "boto3_client_mock", "api.SessionLogResult", "api.LogEvent", "datetime.datetime", "datetime.datetime", "CliRunner", "runner.invoke", "get_job.assert_called_once_with", "boto3_client_mock", "mock_get_logs.assert_called_once_with"]
0
[]
The function (test_cli_job_logs_with_job_id_selects_most_recent_among_multiple_ongoing) defined within the public class called public.The function start at line 807 and ends at 905. It contains 80 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 18.0 functions, and It has 18.0 functions called inside which are ["patch.object", "patch", "patch", "MagicMock", "boto3_client_mock", "datetime.datetime", "datetime.datetime", "datetime.datetime", "boto3_client_mock", "api.SessionLogResult", "api.LogEvent", "datetime.datetime", "datetime.datetime", "CliRunner", "runner.invoke", "get_job.assert_called_once_with", "boto3_client_mock", "mock_get_logs.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_json_with_job_info
def test_cli_job_logs_json_with_job_info(fresh_deadline_config):"""Test that logs CLI includes job information in JSON mode when job-id is provided."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("defaults.job_id", MOCK_JOB_ID)with patch.object(api, "get_boto3_client") as boto3_client_mock, patch.object(api, "get_session_logs") as mock_get_logs:# Mock the paginatorpaginator_mock = MagicMock()boto3_client_mock().get_paginator.return_value = paginator_mock# Set up the paginator to return a single sessionpaginator_mock.paginate.return_value = [{"sessions": [{"sessionId": "session-1"}]}]# Mock get_job to return job nameboto3_client_mock().get_job.return_value = {"name": "Test Job Name"}# Mock the get_session_logs responsemock_get_logs.return_value = SAMPLE_LOG_RESULTrunner = CliRunner()result = runner.invoke(main,["job","logs","--job-id",MOCK_JOB_ID,"--output","json",],)# Verify the output is valid JSONoutput_json = json.loads(result.output)assert "events" in output_jsonassert len(output_json["events"]) == 2assert output_json["events"][0]["message"] == "Log message 1"assert output_json["events"][1]["message"] == "Log message 2"assert output_json["count"] == 2assert output_json["nextToken"] == "next-token"assert output_json["logGroup"] == f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}"assert output_json["logStream"] == "session-test-session"# Verify job information is includedassert output_json["jobId"] == MOCK_JOB_IDassert output_json["jobName"] == "Test Job Name"# Verify no intermediate text output was producedassert "Retrieving logs for session" not in result.outputassert "Using the only available session" not in result.outputassert result.exit_code == 0
1
38
1
246
4
908
964
908
fresh_deadline_config
['runner', 'result', 'output_json', 'paginator_mock']
None
{"Assign": 8, "Expr": 4, "With": 1}
12
57
12
["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "patch.object", "MagicMock", "boto3_client_mock", "boto3_client_mock", "CliRunner", "runner.invoke", "json.loads", "len"]
0
[]
The function (test_cli_job_logs_json_with_job_info) defined within the public class called public.The function start at line 908 and ends at 964. It contains 38 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 12.0 functions, and It has 12.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "patch.object", "MagicMock", "boto3_client_mock", "boto3_client_mock", "CliRunner", "runner.invoke", "json.loads", "len"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_timezone_utc
def test_cli_job_logs_timezone_utc(fresh_deadline_config):"""Test that logs CLI works correctly with UTC timezone (default)."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("defaults.job_id", MOCK_JOB_ID)with patch("deadline.client.api.get_session_logs") as mock_get_logs, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user, patch("deadline.client.api.get_boto3_client") as boto3_client_mock:mock_get_user.return_value = (None, None)mock_get_logs.return_value = SAMPLE_LOG_RESULT# Mock get_job to return job nameboto3_client_mock().get_job.return_value = {"name": "Test Job Name"}runner = CliRunner()result = runner.invoke(main, ["job", "logs", "--session-id", "test-session", "--timezone", "utc"])# Verify UTC timestamps are displayedassert "[2023-01-01T12:00:00.123456+00:00] Log message 1" in result.outputassert "[2023-01-01T12:01:00.789012+00:00] Log message 2" in result.outputassert result.exit_code == 0
1
17
1
124
2
967
992
967
fresh_deadline_config
['runner', 'result']
None
{"Assign": 5, "Expr": 4, "With": 1}
9
26
9
["config.set_setting", "config.set_setting", "config.set_setting", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_job_logs_timezone_utc) defined within the public class called public.The function start at line 967 and ends at 992. It contains 17 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_timezone_local_verbose
def test_cli_job_logs_timezone_local_verbose(fresh_deadline_config):"""Test that logs CLI works correctly with local timezone in verbose mode."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("defaults.job_id", MOCK_JOB_ID)# Create timezone-aware datetime objects for testingimport datetimeutc_time1 = datetime.datetime(2023, 1, 1, 12, 0, 0, 123456, tzinfo=datetime.timezone.utc)utc_time2 = datetime.datetime(2023, 1, 1, 12, 1, 0, 789012, tzinfo=datetime.timezone.utc)timezone_aware_events = [LogEvent(timestamp=utc_time1,message="Log message 1",ingestion_time=datetime.datetime(2023, 1, 1, 12, 0, 10, 654321, tzinfo=datetime.timezone.utc),event_id="event-1",),LogEvent(timestamp=utc_time2,message="Log message 2",ingestion_time=datetime.datetime(2023, 1, 1, 12, 1, 10, 345678, tzinfo=datetime.timezone.utc),event_id="event-2",),]timezone_aware_result = SessionLogResult(events=timezone_aware_events,next_token="next-token",log_group=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",log_stream="session-test-session",count=2,)with patch("deadline.client.api.get_session_logs") as mock_get_logs, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user, patch("deadline.client.api.get_boto3_client") as boto3_client_mock:mock_get_user.return_value = (None, None)mock_get_logs.return_value = timezone_aware_result# Mock get_job to return job nameboto3_client_mock().get_job.return_value = {"name": "Test Job Name"}runner = CliRunner()result = runner.invoke(main, ["job", "logs", "--session-id", "test-session", "--timezone", "local"])# The exact local time will depend on the system timezone, but we can verify# that the format is ISO 8601 and that the command succeedsassert "Log message 1" in result.outputassert "Log message 2" in result.output# Check that timestamps contain 'T' (ISO format) and timezone offsetassert "T" in result.outputassert "+" in result.output or "-" in result.output# timezone offsetassert result.exit_code == 0
2
47
1
320
6
995
1,057
995
fresh_deadline_config
['timezone_aware_events', 'runner', 'utc_time1', 'result', 'timezone_aware_result', 'utc_time2']
None
{"Assign": 9, "Expr": 4, "With": 1}
16
63
16
["config.set_setting", "config.set_setting", "config.set_setting", "datetime.datetime", "datetime.datetime", "LogEvent", "datetime.datetime", "LogEvent", "datetime.datetime", "SessionLogResult", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_job_logs_timezone_local_verbose) defined within the public class called public.The function start at line 995 and ends at 1057. It contains 47 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value. It declares 16.0 functions, and It has 16.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "datetime.datetime", "datetime.datetime", "LogEvent", "datetime.datetime", "LogEvent", "datetime.datetime", "SessionLogResult", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_logs_timezone_local_json
def test_cli_job_logs_timezone_local_json(fresh_deadline_config):"""Test that logs CLI works correctly with local timezone in JSON mode."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("defaults.job_id", MOCK_JOB_ID)# Create timezone-aware datetime objects for testingimport datetimeutc_time1 = datetime.datetime(2023, 1, 1, 12, 0, 0, 123456, tzinfo=datetime.timezone.utc)utc_time2 = datetime.datetime(2023, 1, 1, 12, 1, 0, 789012, tzinfo=datetime.timezone.utc)timezone_aware_events = [LogEvent(timestamp=utc_time1,message="Log message 1",ingestion_time=datetime.datetime(2023, 1, 1, 12, 0, 10, 654321, tzinfo=datetime.timezone.utc),event_id="event-1",),LogEvent(timestamp=utc_time2,message="Log message 2",ingestion_time=datetime.datetime(2023, 1, 1, 12, 1, 10, 345678, tzinfo=datetime.timezone.utc),event_id="event-2",),]timezone_aware_result = SessionLogResult(events=timezone_aware_events,next_token="next-token",log_group=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",log_stream="session-test-session",count=2,)with patch("deadline.client.api.get_session_logs") as mock_get_logs, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user, patch("deadline.client.api.get_boto3_client") as boto3_client_mock:mock_get_user.return_value = (None, None)mock_get_logs.return_value = timezone_aware_result# Mock get_job to return job nameboto3_client_mock().get_job.return_value = {"name": "Test Job Name"}runner = CliRunner()result = runner.invoke(main,["job","logs","--session-id","test-session","--timezone","local","--output","json",],)# Verify the output is valid JSONoutput_json = json.loads(result.output)assert "events" in output_jsonassert len(output_json["events"]) == 2assert output_json["events"][0]["message"] == "Log message 1"assert output_json["events"][1]["message"] == "Log message 2"# Verify timestamps are in ISO 8601 format with timezone infotimestamp1 = output_json["events"][0]["timestamp"]timestamp2 = output_json["events"][1]["timestamp"]ingestion1 = output_json["events"][0]["ingestionTime"]ingestion2 = output_json["events"][1]["ingestionTime"]# Check ISO 8601 format (contains 'T' and timezone offset)assert "T" in timestamp1 and ("+" in timestamp1 or "-" in timestamp1)assert "T" in timestamp2 and ("+" in timestamp2 or "-" in timestamp2)assert "T" in ingestion1 and ("+" in ingestion1 or "-" in ingestion1)assert "T" in ingestion2 and ("+" in ingestion2 or "-" in ingestion2)assert result.exit_code == 0
9
66
1
450
11
1,060
1,144
1,060
fresh_deadline_config
['timestamp1', 'timestamp2', 'ingestion2', 'timezone_aware_events', 'runner', 'output_json', 'utc_time1', 'result', 'ingestion1', 'timezone_aware_result', 'utc_time2']
None
{"Assign": 14, "Expr": 4, "With": 1}
18
85
18
["config.set_setting", "config.set_setting", "config.set_setting", "datetime.datetime", "datetime.datetime", "LogEvent", "datetime.datetime", "LogEvent", "datetime.datetime", "SessionLogResult", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke", "json.loads", "len"]
0
[]
The function (test_cli_job_logs_timezone_local_json) defined within the public class called public.The function start at line 1060 and ends at 1144. It contains 66 lines of code and it has a cyclomatic complexity of 9. The function does not take any parameters and does not return any value. It declares 18.0 functions, and It has 18.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "datetime.datetime", "datetime.datetime", "LogEvent", "datetime.datetime", "LogEvent", "datetime.datetime", "SessionLogResult", "patch", "patch", "patch", "boto3_client_mock", "CliRunner", "runner.invoke", "json.loads", "len"].
aws-deadline_deadline-cloud
public
public
0
0
add_mocks_for_job_requeue_tasks
def add_mocks_for_job_requeue_tasks(deadline_mock):"""Adds mock return values to the deadline_mock for sharing acrossthe different 'deadline job requeue-tasks' tests."""# These mock returns only contain the properties that requeue-tasks needsdeadline_mock.get_job.return_value = {"jobId": MOCK_JOB_ID,"name": "Mock Job","taskRunStatus": "RUNNING","taskRunStatusCounts": {"SUCCEEDED": 1,"SUSPENDED": 1,"CANCELED": 1,"FAILED": 1,"NOT_COMPATIBLE": 1,"RUNNING": 1,},}deadline_mock.list_steps.return_value = {"steps": [{"stepId": MOCK_STEP_ID,"name": "Step Name","taskRunStatus": "RUNNING","taskRunStatusCounts": {"SUCCEEDED": 1,"SUSPENDED": 1,"CANCELED": 1,"FAILED": 1,"NOT_COMPATIBLE": 1,"RUNNING": 1,},}]}deadline_mock.list_tasks.return_value = {"tasks": [{"taskId": f"{MOCK_TASK_ID_PREFIX}-0","runStatus": "SUCCEEDED","parameters": {"TestCase": {"string": "SUCCEEDED task"}},},{"taskId": f"{MOCK_TASK_ID_PREFIX}-1","runStatus": "SUSPENDED","parameters": {"TestCase": {"string": "SUSPENDED task"}},},{"taskId": f"{MOCK_TASK_ID_PREFIX}-2","runStatus": "CANCELED","parameters": {"TestCase": {"string": "CANCELED task"}},},{"taskId": f"{MOCK_TASK_ID_PREFIX}-3","runStatus": "FAILED","parameters": {"TestCase": {"string": "FAILED task"}},},{"taskId": f"{MOCK_TASK_ID_PREFIX}-4","runStatus": "NOT_COMPATIBLE","parameters": {"TestCase": {"string": "NOT_COMPATIBLE task"}},},{"taskId": f"{MOCK_TASK_ID_PREFIX}-5","runStatus": "RUNNING","parameters": {"TestCase": {"string": "RUNNING task"}},},]}deadline_mock.update_task.return_value = {}
1
66
1
274
0
25
95
25
deadline_mock
[]
None
{"Assign": 4, "Expr": 1}
0
71
0
[]
4
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_multiple_statuses", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_of_each_status", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_user_says_no"]
The function (add_mocks_for_job_requeue_tasks) defined within the public class called public.The function start at line 25 and ends at 95. It contains 66 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It has 4.0 functions calling this function which are ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_multiple_statuses", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_of_each_status", "_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_job_requeue_tasks_py.test_cli_job_requeue_tasks_user_says_no"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_requeue_tasks
def test_cli_job_requeue_tasks(fresh_deadline_config, deadline_mock):"""Tests that 'deadline job requeue-tasks' requeues all the tasks of the correct run status."""add_mocks_for_job_requeue_tasks(deadline_mock)with patch.object(click, "confirm") as mock_confirm:mock_confirm.return_value = Truerunner = CliRunner()result = runner.invoke(main,["job","requeue-tasks","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--job-id",MOCK_JOB_ID,],)assert (result.output== f"""Job: Mock Job ({MOCK_JOB_ID})taskRunStatusCounts:SUCCEEDED: 1SUSPENDED: 1CANCELED: 1FAILED: 1NOT_COMPATIBLE: 1RUNNING: 1Requeuing all tasks with run status among: CANCELED, FAILED, SUSPENDEDThis action will requeue an estimated 3 total tasks (1 SUSPENDED tasks, 1 CANCELED tasks, 1 FAILED tasks)Requeuing tasks...Step: Step Name ({MOCK_STEP_ID})Requeuing an estimated 3 total tasks (1 SUSPENDED tasks, 1 CANCELED tasks, 1 FAILED tasks)...SUSPENDED TestCase=SUSPENDED task ({MOCK_TASK_ID_PREFIX}-1)CANCELED TestCase=CANCELED task ({MOCK_TASK_ID_PREFIX}-2)FAILED TestCase=FAILED task ({MOCK_TASK_ID_PREFIX}-3)Requeued a total of 3 tasks.""")mock_confirm.assert_called_once_with("Are you sure you want to requeue these tasks?", default=None)assert deadline_mock.update_task.call_args_list == [call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=f"{MOCK_TASK_ID_PREFIX}-1",targetRunStatus="PENDING",),call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=f"{MOCK_TASK_ID_PREFIX}-2",targetRunStatus="PENDING",),call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=f"{MOCK_TASK_ID_PREFIX}-3",targetRunStatus="PENDING",),]
1
50
2
177
2
98
173
98
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 3, "With": 1}
8
76
8
["add_mocks_for_job_requeue_tasks", "patch.object", "CliRunner", "runner.invoke", "mock_confirm.assert_called_once_with", "call", "call", "call"]
0
[]
The function (test_cli_job_requeue_tasks) defined within the public class called public.The function start at line 98 and ends at 173. It contains 50 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [98.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["add_mocks_for_job_requeue_tasks", "patch.object", "CliRunner", "runner.invoke", "mock_confirm.assert_called_once_with", "call", "call", "call"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_requeue_tasks_user_says_no
def test_cli_job_requeue_tasks_user_says_no(fresh_deadline_config, deadline_mock):"""Tests that 'deadline job requeue-tasks' requeues nothing if the user says "no" to the confirmation prompt."""add_mocks_for_job_requeue_tasks(deadline_mock)with patch.object(click, "confirm") as mock_confirm:mock_confirm.return_value = Falserunner = CliRunner()result = runner.invoke(main,["job","requeue-tasks","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--job-id",MOCK_JOB_ID,],)assert (result.output== f"""Job: Mock Job ({MOCK_JOB_ID})taskRunStatusCounts:SUCCEEDED: 1SUSPENDED: 1CANCELED: 1FAILED: 1NOT_COMPATIBLE: 1RUNNING: 1Requeuing all tasks with run status among: CANCELED, FAILED, SUSPENDEDThis action will requeue an estimated 3 total tasks (1 SUSPENDED tasks, 1 CANCELED tasks, 1 FAILED tasks)No tasks were requeued.""")mock_confirm.assert_called_once_with("Are you sure you want to requeue these tasks?", default=None)assert deadline_mock.update_task.call_args_list == []
1
25
2
90
2
176
218
176
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 3, "With": 1}
5
43
5
["add_mocks_for_job_requeue_tasks", "patch.object", "CliRunner", "runner.invoke", "mock_confirm.assert_called_once_with"]
0
[]
The function (test_cli_job_requeue_tasks_user_says_no) defined within the public class called public.The function start at line 176 and ends at 218. It contains 25 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [176.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["add_mocks_for_job_requeue_tasks", "patch.object", "CliRunner", "runner.invoke", "mock_confirm.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_requeue_tasks_of_each_status
def test_cli_job_requeue_tasks_of_each_status(run_status, task_id, fresh_deadline_config, deadline_mock):"""Tests that 'deadline job requeue-tasks' requeues the one task of each selected run status."""add_mocks_for_job_requeue_tasks(deadline_mock)runner = CliRunner()result = runner.invoke(main,["job","requeue-tasks","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--job-id",MOCK_JOB_ID,"--yes","--run-status",run_status,],)assert (result.output== f"""Job: Mock Job ({MOCK_JOB_ID})taskRunStatusCounts:SUCCEEDED: 1SUSPENDED: 1CANCELED: 1FAILED: 1NOT_COMPATIBLE: 1RUNNING: 1Requeuing all tasks with run status among: {run_status}Estimated 1 total tasks (1 {run_status} tasks) to requeue.Step: Step Name ({MOCK_STEP_ID})Requeuing an estimated 1 total tasks (1 {run_status} tasks)...{run_status} TestCase={run_status} task ({task_id})Requeued a total of 1 tasks.""")assert deadline_mock.update_task.call_args_list == [call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=task_id,targetRunStatus="PENDING",),]
1
34
4
101
2
231
287
231
run_status,task_id,fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 2, "Expr": 2}
5
57
5
["add_mocks_for_job_requeue_tasks", "CliRunner", "runner.invoke", "call", "pytest.mark.parametrize"]
0
[]
The function (test_cli_job_requeue_tasks_of_each_status) defined within the public class called public.The function start at line 231 and ends at 287. It contains 34 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [231.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["add_mocks_for_job_requeue_tasks", "CliRunner", "runner.invoke", "call", "pytest.mark.parametrize"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_job_requeue_tasks_multiple_statuses
def test_cli_job_requeue_tasks_multiple_statuses(fresh_deadline_config, deadline_mock):"""Tests that 'deadline job requeue-tasks' requeues all statuses provided with repeated--run-status options."""add_mocks_for_job_requeue_tasks(deadline_mock)runner = CliRunner()result = runner.invoke(main,["job","requeue-tasks","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--job-id",MOCK_JOB_ID,"--run-status","CANCELED","--yes","--run-status","FAILED",],)assert (result.output== f"""Job: Mock Job ({MOCK_JOB_ID})taskRunStatusCounts:SUCCEEDED: 1SUSPENDED: 1CANCELED: 1FAILED: 1NOT_COMPATIBLE: 1RUNNING: 1Requeuing all tasks with run status among: CANCELED, FAILEDEstimated 2 total tasks (1 CANCELED tasks, 1 FAILED tasks) to requeue.Step: Step Name ({MOCK_STEP_ID})Requeuing an estimated 2 total tasks (1 CANCELED tasks, 1 FAILED tasks)...CANCELED TestCase=CANCELED task ({MOCK_TASK_ID_PREFIX}-2)FAILED TestCase=FAILED task ({MOCK_TASK_ID_PREFIX}-3)Requeued a total of 2 tasks.""")assert deadline_mock.update_task.call_args_list == [call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=f"{MOCK_TASK_ID_PREFIX}-2",targetRunStatus="PENDING",),call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,jobId=MOCK_JOB_ID,stepId=MOCK_STEP_ID,taskId=f"{MOCK_TASK_ID_PREFIX}-3",targetRunStatus="PENDING",),]
1
42
2
131
2
290
356
290
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 2, "Expr": 2}
5
67
5
["add_mocks_for_job_requeue_tasks", "CliRunner", "runner.invoke", "call", "call"]
0
[]
The function (test_cli_job_requeue_tasks_multiple_statuses) defined within the public class called public.The function start at line 290 and ends at 356. It contains 42 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [290.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["add_mocks_for_job_requeue_tasks", "CliRunner", "runner.invoke", "call", "call"].
aws-deadline_deadline-cloud
public
public
0
0
mock_cachedb
def mock_cachedb():mock_hash_cache = MagicMock(spec=HashCache)mock_hash_cache.__enter__.return_value = mock_hash_cachemock_hash_cache.__exit__.return_value = Nonereturn mock_hash_cache
1
5
0
28
1
24
28
24
['mock_hash_cache']
Returns
{"Assign": 3, "Return": 1}
1
5
1
["MagicMock"]
0
[]
The function (mock_cachedb) defined within the public class called public.The function start at line 24 and ends at 28. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declare 1.0 function, and It has 1.0 function called inside which is ["MagicMock"].
aws-deadline_deadline-cloud
public
public
0
0
mock_prepare_paths_for_upload
def mock_prepare_paths_for_upload():with patch.object(S3AssetManager, "prepare_paths_for_upload") as mock:yield mock
1
3
0
18
0
32
34
32
[]
None
{"Expr": 1, "With": 1}
1
3
1
["patch.object"]
0
[]
The function (mock_prepare_paths_for_upload) defined within the public class called public.The function start at line 32 and ends at 34. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, and It has 1.0 function called inside which is ["patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
mock_hash_attachments
def mock_hash_attachments():with patch("deadline.job_attachments.api.manifest._hash_attachments", return_value=(Mock(), [])) as mock:yield mock
1
5
0
25
0
38
42
38
[]
None
{"Expr": 1, "With": 1}
2
5
2
["patch", "Mock"]
0
[]
The function (mock_hash_attachments) defined within the public class called public.The function start at line 38 and ends at 42. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["patch", "Mock"].
aws-deadline_deadline-cloud
public
public
0
0
basic_asset_group
def basic_asset_group(tmp_path):root_dir = str(tmp_path)return AssetRootGroup(root_path=root_dir,inputs=set(),outputs=set(),references=set(),)
1
8
1
37
1
46
53
46
tmp_path
['root_dir']
Returns
{"Assign": 1, "Return": 1}
5
8
5
["str", "AssetRootGroup", "set", "set", "set"]
0
[]
The function (basic_asset_group) defined within the public class called public.The function start at line 46 and ends at 53. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["str", "AssetRootGroup", "set", "set", "set"].
aws-deadline_deadline-cloud
public
public
0
0
mock_upload_group
def mock_upload_group(basic_asset_group):return Mock(asset_groups=[basic_asset_group],total_input_files=1,total_input_bytes=100,)
1
6
1
23
0
57
62
57
basic_asset_group
[]
Returns
{"Return": 1}
1
6
1
["Mock"]
0
[]
The function (mock_upload_group) defined within the public class called public.The function start at line 57 and ends at 62. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declare 1.0 function, and It has 1.0 function called inside which is ["Mock"].
aws-deadline_deadline-cloud
public
public
0
0
basic_asset_manifest
def basic_asset_manifest():return AssetManifest(paths=[], hash_alg=HashAlgorithm("xxh128"), total_size=0)
1
2
0
23
0
66
67
66
[]
Returns
{"Return": 1}
2
2
2
["AssetManifest", "HashAlgorithm"]
0
[]
The function (basic_asset_manifest) defined within the public class called public.The function start at line 66 and ends at 67. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["AssetManifest", "HashAlgorithm"].
aws-deadline_deadline-cloud
public
public
0
0
mock_attachment_settings
def mock_attachment_settings():return Attachments(manifests=[], fileSystem="").to_dict
1
2
0
18
0
71
72
71
[]
Returns
{"Return": 1}
1
2
1
["Attachments"]
0
[]
The function (mock_attachment_settings) defined within the public class called public.The function start at line 71 and ends at 72. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declare 1.0 function, and It has 1.0 function called inside which is ["Attachments"].
aws-deadline_deadline-cloud
public
public
0
0
mock_init_objects
def mock_init_objects():with patch.object(S3AssetManager, "__init__", lambda self, *args, **kwargs: None), patch.object(S3AssetUploader, "__init__", lambda self, *args, **kwargs: None), patch.object(JobAttachmentS3Settings, "__init__", lambda self, *args, **kwargs: None):yield
1
5
0
66
0
76
80
76
[]
None
{"Expr": 1, "With": 1}
3
5
3
["patch.object", "patch.object", "patch.object"]
0
[]
The function (mock_init_objects) defined within the public class called public.The function start at line 76 and ends at 80. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 3.0 functions, and It has 3.0 functions called inside which are ["patch.object", "patch.object", "patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
mock_update_manifest
def mock_update_manifest(basic_asset_manifest):with patch.object(manifest_group, "update_manifest", return_value=basic_asset_manifest) as mock:yield mock
1
3
1
23
0
84
86
84
basic_asset_manifest
[]
None
{"Expr": 1, "With": 1}
1
3
1
["patch.object"]
0
[]
The function (mock_update_manifest) defined within the public class called public.The function start at line 84 and ends at 86. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, and It has 1.0 function called inside which is ["patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
mock_upload_attachments
def mock_upload_attachments():with patch.object(_submit_job_bundle.api, "_upload_attachments", return_value=MOCK_UPLOAD_ATTACHMENTS_RESPONSE) as mock:yield mock
1
5
0
24
0
90
94
90
[]
None
{"Expr": 1, "With": 1}
1
5
1
["patch.object"]
0
[]
The function (mock_upload_attachments) defined within the public class called public.The function start at line 90 and ends at 94. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, and It has 1.0 function called inside which is ["patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
mock_create_manifest_file._mock_create_manifest_file
def _mock_create_manifest_file(input_paths, root_path, hash_cache):return AssetManifest(paths=[BaseManifestPath(path=os.path.join(root_path, "file1.txt"), hash="mock_hash_1", size=0, mtime=0),BaseManifestPath(path=os.path.join(root_path, "subdir1", "file2.txt"),hash="mock_hash_2",size=0,mtime=0,),BaseManifestPath(path=os.path.join(root_path, "subdir2", "subdir3", "file3.txt"),hash="mock_hash_3",size=0,mtime=0,),],hash_alg=HashAlgorithm("xxh128"),total_size=0,)
1
22
3
121
0
99
120
99
null
[]
None
null
0
0
0
null
0
null
The function (mock_create_manifest_file._mock_create_manifest_file) defined within the public class called public.The function start at line 99 and ends at 120. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [99.0] and does not return any value..
aws-deadline_deadline-cloud
public
public
0
0
mock_create_manifest_file
def mock_create_manifest_file():def _mock_create_manifest_file(input_paths, root_path, hash_cache):return AssetManifest(paths=[BaseManifestPath(path=os.path.join(root_path, "file1.txt"), hash="mock_hash_1", size=0, mtime=0),BaseManifestPath(path=os.path.join(root_path, "subdir1", "file2.txt"),hash="mock_hash_2",size=0,mtime=0,),BaseManifestPath(path=os.path.join(root_path, "subdir2", "subdir3", "file3.txt"),hash="mock_hash_3",size=0,mtime=0,),],hash_alg=HashAlgorithm("xxh128"),total_size=0,)with patch.object(S3AssetManager, "_create_manifest_file", side_effect=_mock_create_manifest_file):yield
1
6
0
21
0
98
125
98
[]
Returns
{"Expr": 1, "Return": 1, "With": 1}
9
28
9
["AssetManifest", "BaseManifestPath", "os.path.join", "BaseManifestPath", "os.path.join", "BaseManifestPath", "os.path.join", "HashAlgorithm", "patch.object"]
0
[]
The function (mock_create_manifest_file) defined within the public class called public.The function start at line 98 and ends at 125. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["AssetManifest", "BaseManifestPath", "os.path.join", "BaseManifestPath", "os.path.join", "BaseManifestPath", "os.path.join", "HashAlgorithm", "patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
mock_read_local_manifest._mock_read_local_manifest
def _mock_read_local_manifest(manifest):return AssetManifest(paths=[BaseManifestPath(path="file1.txt", hash="old_hash_1", size=0, mtime=0),BaseManifestPath(path="subdir1/file2.txt", hash="old_hash_2", size=0, mtime=0),BaseManifestPath(path="subdir2/subdir3/file3.txt", hash="old_hash_3", size=0, mtime=0),],hash_alg=HashAlgorithm("xxh128"),total_size=0,)
1
12
1
82
0
130
141
130
null
[]
None
null
0
0
0
null
0
null
The function (mock_read_local_manifest._mock_read_local_manifest) defined within the public class called public.The function start at line 130 and ends at 141. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
aws-deadline_deadline-cloud
public
public
0
0
mock_read_local_manifest
def mock_read_local_manifest():def _mock_read_local_manifest(manifest):return AssetManifest(paths=[BaseManifestPath(path="file1.txt", hash="old_hash_1", size=0, mtime=0),BaseManifestPath(path="subdir1/file2.txt", hash="old_hash_2", size=0, mtime=0),BaseManifestPath(path="subdir2/subdir3/file3.txt", hash="old_hash_3", size=0, mtime=0),],hash_alg=HashAlgorithm("xxh128"),total_size=0,)with patch.object(manifest_group, "read_local_manifest", side_effect=_mock_read_local_manifest):yield
1
4
0
21
0
129
144
129
[]
Returns
{"Expr": 1, "Return": 1, "With": 1}
6
16
6
["AssetManifest", "BaseManifestPath", "BaseManifestPath", "BaseManifestPath", "HashAlgorithm", "patch.object"]
0
[]
The function (mock_read_local_manifest) defined within the public class called public.The function start at line 129 and ends at 144. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["AssetManifest", "BaseManifestPath", "BaseManifestPath", "BaseManifestPath", "HashAlgorithm", "patch.object"].
aws-deadline_deadline-cloud
TestSnapshot
public
0
0
test_snapshot_root_directory_only
def test_snapshot_root_directory_only(self, tmp_path, mock_prepare_paths_for_upload, mock_hash_attachments, mock_upload_group):"""Tests if CLI snapshot command calls correctly with an exiting directory path at --root"""root_dir = str(tmp_path)temp_file = tmp_path / "temp_file.txt"temp_file.touch()mock_prepare_paths_for_upload.return_value = mock_upload_grouprunner = CliRunner()result = runner.invoke(main, ["manifest", "snapshot", "--root", root_dir])assert result.exit_code == 0mock_prepare_paths_for_upload.assert_called_once_with(input_paths=[str(temp_file)], output_paths=[root_dir], referenced_paths=[])mock_hash_attachments.assert_called_once()
1
14
5
93
0
174
194
174
self,tmp_path,mock_prepare_paths_for_upload,mock_hash_attachments,mock_upload_group
[]
None
{"Assign": 5, "Expr": 4}
7
21
7
["str", "temp_file.touch", "CliRunner", "runner.invoke", "mock_prepare_paths_for_upload.assert_called_once_with", "str", "mock_hash_attachments.assert_called_once"]
0
[]
The function (test_snapshot_root_directory_only) defined within the public class called TestSnapshot.The function start at line 174 and ends at 194. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [174.0] and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["str", "temp_file.touch", "CliRunner", "runner.invoke", "mock_prepare_paths_for_upload.assert_called_once_with", "str", "mock_hash_attachments.assert_called_once"].
aws-deadline_deadline-cloud
TestSnapshot
public
0
0
test_invalid_root_directory
def test_invalid_root_directory(self, tmp_path):"""Tests if CLI snapshot raises error when called with an invalid --root with non-existing directory path"""invalid_root_dir = str(tmp_path / "invalid_dir")runner = CliRunner()result = runner.invoke(main, ["manifest", "snapshot", "--root", invalid_root_dir])assert result.exit_code != 0assert f"{invalid_root_dir}" in result.output
1
6
2
52
0
196
206
196
self,tmp_path
[]
None
{"Assign": 3, "Expr": 1}
3
11
3
["str", "CliRunner", "runner.invoke"]
0
[]
The function (test_invalid_root_directory) defined within the public class called TestSnapshot.The function start at line 196 and ends at 206. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [196.0] and does not return any value. It declares 3.0 functions, and It has 3.0 functions called inside which are ["str", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
TestSnapshot
public
0
0
test_valid_manifest_out
def test_valid_manifest_out(self, tmp_path, mock_prepare_paths_for_upload, mock_hash_attachments, mock_upload_group):"""Tests if CLI snapshot command correctly calls with --manifest-out arguement"""root_dir = str(tmp_path)manifest_out_dir = tmp_path / "manifest_out"manifest_out_dir.mkdir()temp_file = tmp_path / "temp_file.txt"temp_file.touch()mock_prepare_paths_for_upload.return_value = mock_upload_grouprunner = CliRunner()result = runner.invoke(main,["manifest","snapshot","--root",root_dir,],)assert result.exit_code == 0mock_prepare_paths_for_upload.assert_called_once_with(input_paths=[str(temp_file)], output_paths=[root_dir], referenced_paths=[])mock_hash_attachments.assert_called_once()
1
24
5
105
0
208
238
208
self,tmp_path,mock_prepare_paths_for_upload,mock_hash_attachments,mock_upload_group
[]
None
{"Assign": 6, "Expr": 5}
8
31
8
["str", "manifest_out_dir.mkdir", "temp_file.touch", "CliRunner", "runner.invoke", "mock_prepare_paths_for_upload.assert_called_once_with", "str", "mock_hash_attachments.assert_called_once"]
0
[]
The function (test_valid_manifest_out) defined within the public class called TestSnapshot.The function start at line 208 and ends at 238. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [208.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["str", "manifest_out_dir.mkdir", "temp_file.touch", "CliRunner", "runner.invoke", "mock_prepare_paths_for_upload.assert_called_once_with", "str", "mock_hash_attachments.assert_called_once"].
aws-deadline_deadline-cloud
TestSnapshot
public
0
0
test_invalid_manifest_out
def test_invalid_manifest_out(self, tmp_path):"""Tests if CLI snapshot raises error when called with invalid --destination with non-existing directory path"""root_dir = str(tmp_path)invalid_manifest_out = str(tmp_path / "nonexistent_dir")runner = CliRunner()result = runner.invoke(main,["manifest", "snapshot", "--root", root_dir, "--destination", invalid_manifest_out],)assert result.exit_code != 0assert f"{invalid_manifest_out}" in result.output
1
10
2
63
0
240
254
240
self,tmp_path
[]
None
{"Assign": 4, "Expr": 1}
4
15
4
["str", "str", "CliRunner", "runner.invoke"]
0
[]
The function (test_invalid_manifest_out) defined within the public class called TestSnapshot.The function start at line 240 and ends at 254. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [240.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["str", "str", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
TestSnapshot
public
0
0
test_asset_snapshot_recursive
def test_asset_snapshot_recursive(self, tmp_path, mock_prepare_paths_for_upload, mock_hash_attachments, mock_upload_group):"""Tests if CLI snapshot works with snapshotting directories with nested data."""root_dir = str(tmp_path)subdir1 = tmp_path / "subdir1"subdir2 = tmp_path / "subdir2"subdir1.mkdir()subdir2.mkdir()(subdir1 / "file1.txt").touch()(subdir2 / "file2.txt").touch()expected_inputs = {str(subdir2 / "file2.txt"), str(subdir1 / "file1.txt")}mock_prepare_paths_for_upload.return_value = mock_upload_grouprunner = CliRunner()result = runner.invoke(main, ["manifest", "snapshot", "--root", root_dir])assert result.exit_code == 0actual_inputs = set(mock_prepare_paths_for_upload.call_args[1]["input_paths"])assert actual_inputs == expected_inputsmock_hash_attachments.assert_called_once()
1
18
5
132
0
256
279
256
self,tmp_path,mock_prepare_paths_for_upload,mock_hash_attachments,mock_upload_group
[]
None
{"Assign": 8, "Expr": 6}
11
24
11
["str", "subdir1.mkdir", "subdir2.mkdir", "touch", "touch", "str", "str", "CliRunner", "runner.invoke", "set", "mock_hash_attachments.assert_called_once"]
0
[]
The function (test_asset_snapshot_recursive) defined within the public class called TestSnapshot.The function start at line 256 and ends at 279. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [256.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["str", "subdir1.mkdir", "subdir2.mkdir", "touch", "touch", "str", "str", "CliRunner", "runner.invoke", "set", "mock_hash_attachments.assert_called_once"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_list
def test_cli_queue_list(fresh_deadline_config, mock_telemetry):"""Confirm that the CLI interface prints out the expected list ofqueues, given mock data."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)with patch.object(api._session, "get_boto3_session") as session_mock:session_mock().client("deadline").list_queues.return_value = {"queues": MOCK_QUEUES_LIST}runner = CliRunner()result = runner.invoke(main, ["queue", "list"])assert (result.output== """- queueId: queue-0123456789abcdef0123456789abcdefdisplayName: Testing Queue- queueId: queue-0123456789abcdef0123456789abcdegdisplayName: Another Queue""")assert result.exit_code == 0
1
10
2
81
2
19
41
19
fresh_deadline_config,mock_telemetry
['runner', 'result']
None
{"Assign": 3, "Expr": 2, "With": 1}
6
23
6
["config.set_setting", "patch.object", "client", "session_mock", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_queue_list) defined within the public class called public.The function start at line 19 and ends at 41. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [19.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["config.set_setting", "patch.object", "client", "session_mock", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_list_explicit_farm_id
def test_cli_queue_list_explicit_farm_id(fresh_deadline_config, mock_telemetry):"""Confirm that the CLI interface prints out the expected list ofqueues, given mock data."""with patch.object(api._session, "get_boto3_session") as session_mock:session_mock().client("deadline").list_queues.return_value = {"queues": MOCK_QUEUES_LIST}runner = CliRunner()result = runner.invoke(main, ["queue", "list", "--farm-id", MOCK_FARM_ID])assert (result.output== """- queueId: queue-0123456789abcdef0123456789abcdefdisplayName: Testing Queue- queueId: queue-0123456789abcdef0123456789abcdegdisplayName: Another Queue""")assert result.exit_code == 0
1
9
2
77
2
44
64
44
fresh_deadline_config,mock_telemetry
['runner', 'result']
None
{"Assign": 3, "Expr": 1, "With": 1}
5
21
5
["patch.object", "client", "session_mock", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_queue_list_explicit_farm_id) defined within the public class called public.The function start at line 44 and ends at 64. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [44.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["patch.object", "client", "session_mock", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_list_override_profile
def test_cli_queue_list_override_profile(fresh_deadline_config):"""Confirms that the --profile option overrides the option to boto3.Session."""# set the farm id for the overridden profileconfig.set_setting("defaults.aws_profile_name", "NonDefaultProfileName")config.set_setting("defaults.farm_id", "farm-overriddenid")config.set_setting("defaults.aws_profile_name", "DifferentProfileName")with patch.object(boto3, "Session") as session_mock:session_mock().client("deadline").list_queues.return_value = {"queues": MOCK_QUEUES_LIST}session_mock.reset_mock()runner = CliRunner()result = runner.invoke(main, ["queue", "list", "--profile", "NonDefaultProfileName"])assert result.exit_code == 0session_mock.assert_called_with(profile_name="NonDefaultProfileName")session_mock().client().list_queues.assert_called_once_with(farmId="farm-overriddenid")
1
12
1
118
2
67
85
67
fresh_deadline_config
['runner', 'result']
None
{"Assign": 3, "Expr": 7, "With": 1}
13
19
13
["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "client", "session_mock", "session_mock.reset_mock", "CliRunner", "runner.invoke", "session_mock.assert_called_with", "list_queues.assert_called_once_with", "client", "session_mock"]
0
[]
The function (test_cli_queue_list_override_profile) defined within the public class called public.The function start at line 67 and ends at 85. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 13.0 functions, and It has 13.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "client", "session_mock", "session_mock.reset_mock", "CliRunner", "runner.invoke", "session_mock.assert_called_with", "list_queues.assert_called_once_with", "client", "session_mock"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_list_no_farm_id
def test_cli_queue_list_no_farm_id(fresh_deadline_config):with patch.object(api._session, "get_boto3_session") as session_mock:session_mock().client("deadline").list_queues.return_value = {"queues": MOCK_QUEUES_LIST}runner = CliRunner()result = runner.invoke(main, ["queue", "list"])assert "Missing '--farm-id' or default Farm ID configuration" in result.outputassert result.exit_code != 0
1
7
1
68
2
88
96
88
fresh_deadline_config
['runner', 'result']
None
{"Assign": 3, "With": 1}
5
9
5
["patch.object", "client", "session_mock", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_queue_list_no_farm_id) defined within the public class called public.The function start at line 88 and ends at 96. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["patch.object", "client", "session_mock", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_list_client_error
def test_cli_queue_list_client_error(fresh_deadline_config):config.set_setting("defaults.farm_id", MOCK_FARM_ID)with patch.object(api._session, "get_boto3_session") as session_mock:session_mock().client("deadline").list_queues.side_effect = ClientError({"Error": {"Message": "A botocore client error"}}, "client error")runner = CliRunner()result = runner.invoke(main, ["queue", "list"])assert "Failed to get Queues" in result.outputassert "A botocore client error" in result.outputassert result.exit_code != 0
1
11
1
91
2
99
112
99
fresh_deadline_config
['runner', 'result']
None
{"Assign": 3, "Expr": 1, "With": 1}
7
14
7
["config.set_setting", "patch.object", "client", "session_mock", "ClientError", "CliRunner", "runner.invoke"]
0
[]
The function (test_cli_queue_list_client_error) defined within the public class called public.The function start at line 99 and ends at 112. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["config.set_setting", "patch.object", "client", "session_mock", "ClientError", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_queue_get
def test_cli_queue_get(fresh_deadline_config):"""Confirm that the CLI interface prints out the expected queue, given mock data."""with patch.object(api._session, "get_boto3_session") as session_mock:session_mock().client("deadline").get_queue.return_value = MOCK_QUEUES_LIST[0]runner = CliRunner()result = runner.invoke(main,["queue","get","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUES_LIST[0]["queueId"],],)assert (result.output== """queueId: queue-0123456789abcdef0123456789abcdefdisplayName: Testing Queuedescription: ''""")session_mock().client("deadline").get_queue.assert_called_once_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUES_LIST[0]["queueId"])assert result.exit_code == 0
1
22
1
113
2
115
147
115
fresh_deadline_config
['runner', 'result']
None
{"Assign": 3, "Expr": 2, "With": 1}
8
33
8
["patch.object", "client", "session_mock", "CliRunner", "runner.invoke", "get_queue.assert_called_once_with", "client", "session_mock"]
0
[]
The function (test_cli_queue_get) defined within the public class called public.The function start at line 115 and ends at 147. It contains 22 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["patch.object", "client", "session_mock", "CliRunner", "runner.invoke", "get_queue.assert_called_once_with", "client", "session_mock"].
aws-deadline_deadline-cloud
public
public
0
0
checkpoint_dir
def checkpoint_dir(tmp_path_factory):"""Create a checkpoint directory for all tests to use."""checkpoint_dir = tmp_path_factory.mktemp("checkpoint")yield str(checkpoint_dir)
1
3
1
19
1
53
56
53
tmp_path_factory
['checkpoint_dir']
None
{"Assign": 1, "Expr": 2}
2
4
2
["tmp_path_factory.mktemp", "str"]
0
[]
The function (checkpoint_dir) defined within the public class called public.The function start at line 53 and ends at 56. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["tmp_path_factory.mktemp", "str"].
aws-deadline_deadline-cloud
public
public
0
0
deadline_telemetry_client_mock
def deadline_telemetry_client_mock():with patch.object(deadline.client.api, "get_deadline_cloud_library_telemetry_client") as m:yield m
1
3
0
22
0
61
63
61
[]
None
{"Expr": 1, "With": 1}
1
3
1
["patch.object"]
1
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_queue_incremental_download_py.test_incremental_output_download_stats_telemetry"]
The function (deadline_telemetry_client_mock) defined within the public class called public.The function start at line 61 and ends at 63. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, It has 1.0 function called inside which is ["patch.object"], It has 1.0 function calling this function which is ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_queue_incremental_download_py.test_incremental_output_download_stats_telemetry"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_requires_queue_with_job_attachments
def test_incremental_output_download_requires_queue_with_job_attachments(fresh_deadline_config, deadline_mock, checkpoint_dir):# The response does not include the "jobAttachmentSettings" fielddeadline_mock.get_queue.return_value = {"queueId": MOCK_QUEUE_ID,"displayName": "Mock Queue",}# Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 1, result.outputassert "Queue 'Mock Queue' does not have job attachments configured." in result.output, (result.output)
1
27
3
88
2
69
101
69
fresh_deadline_config,deadline_mock,checkpoint_dir
['runner', 'result']
None
{"Assign": 3, "With": 1}
4
33
4
["CliRunner", "freeze_time", "runner.invoke", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_requires_queue_with_job_attachments) defined within the public class called public.The function start at line 69 and ends at 101. It contains 27 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [69.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["CliRunner", "freeze_time", "runner.invoke", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_pid_lock_already_held_error
def test_incremental_output_download_pid_lock_already_held_error(fresh_deadline_config,deadline_mock,checkpoint_dir,):"""Test incremental_output_download when PidLockAlreadyHeld is raised"""# Write a fake PID to the filepid_lock_file = os.path.join(checkpoint_dir, f"{MOCK_QUEUE_ID}_ignore-storage-profiles_download_checkpoint.json.pid")with open(pid_lock_file, "w") as f:f.write("12345678")# Use a fake PID# Run the CLI commandrunner = CliRunner()with patch.object(psutil, "pid_exists") as mock_pid_exists:# Make psutil.pid_exists return True to simulate the process is runningmock_pid_exists.return_value = Trueresult = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command did not execute successfully and wrote a message about another download in progressassert result.exit_code == 1, result.outputassert (f"Unable to perform incremental output download as process with pid 12345678 already holds the lock {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json.pid')}"in result.output), result.output# Verify the PID file still exists since we're simulating another process holding the lockassert os.path.exists(pid_lock_file)
1
33
3
124
3
107
148
107
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'pid_lock_file']
None
{"Assign": 4, "Expr": 2, "With": 2}
9
42
9
["os.path.join", "open", "f.write", "CliRunner", "patch.object", "runner.invoke", "os.path.join", "os.path.exists", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_pid_lock_already_held_error) defined within the public class called public.The function start at line 107 and ends at 148. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [107.0] and does not return any value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["os.path.join", "open", "f.write", "CliRunner", "patch.object", "runner.invoke", "os.path.join", "os.path.exists", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_storage_profile_options_mutually_exclusive
def test_incremental_output_download_storage_profile_options_mutually_exclusive(fresh_deadline_config,deadline_mock,checkpoint_dir,):"""Test that --storage-profile-id and --ignore-storage-profiles can't be provided together"""# Run the CLI commandrunner = CliRunner()with patch.object(psutil, "pid_exists") as mock_pid_exists:# Make psutil.pid_exists return True to simulate the process is runningmock_pid_exists.return_value = Trueresult = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--storage-profile-id",MOCK_STORAGE_PROFILE_ID,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)assert result.exit_code != 0, result.outputassert ("Options '--storage-profile-id' and '--ignore-storage-profiles' cannot be provided together"in result.output), result.output
1
29
3
89
2
154
187
154
fresh_deadline_config,deadline_mock,checkpoint_dir
['runner', 'result']
None
{"Assign": 3, "Expr": 1, "With": 1}
4
34
4
["CliRunner", "patch.object", "runner.invoke", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_storage_profile_options_mutually_exclusive) defined within the public class called public.The function start at line 154 and ends at 187. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [154.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["CliRunner", "patch.object", "runner.invoke", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_bootstrap_and_completion
def test_incremental_output_download_bootstrap_and_completion(fresh_deadline_config,deadline_mock,checkpoint_dir,storage_profile_id,):"""Test a new job through bootstrap, completion, and retirement. Both without storage profiles,and with the job storage profile matching the local one."""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}del mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operationif storage_profile_id is None:storage_profile_options = ["--ignore-storage-profiles"]else:storage_profile_options = ["--storage-profile-id", storage_profile_id]mock_jobs[0]["storageProfileId"] = storage_profile_idrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output",]+ storage_profile_options+ ["--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.outputif storage_profile_id is None:storage_profile_in_message = "ignore-storage-profiles"else:storage_profile_in_message = storage_profile_id# Assert that information is or isn't printed about the storage profile.if storage_profile_id is None:assert "Local storage profile is" not in result.output, result.outputassert ("download candidate jobs have the same storage profile and will be downloaded to their original specified paths"not in result.output), result.outputelse:assert "Local storage profile is" in result.output, result.outputassert f"({storage_profile_id})" in result.output, result.outputassert ("1 download candidate jobs have the same storage profile and will be downloaded to their original specified paths"in result.output), result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_' + storage_profile_in_message + '_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 0.0 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 1 / 2" in result.output, result.outputassert "added: 1" in result.output, result.output# Edit the mock job to complete the taskmock_jobs[0]["taskRunStatus"] = "SUCCEEDED"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 2,"READY": 0,}mock_jobs[0]["endedAt"] = datetime.fromisoformat(ISO_FREEZE_TIME)# RUN 2: Run the CLI command again to "complete" the download that was started# 3 minutes later is after the consistency window, so that the call after this# sees the job being retired.with freeze_time(ISO_FREEZE_TIME_PLUS_3MIN):result = runner.invoke(main,["queue","sync-output",]+ storage_profile_options+ ["--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_' + storage_profile_in_message + '_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"EXISTING Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks (before): 1 / 2" in result.output, result.outputassert "Succeeded tasks (now) : 2 / 2" in result.output, result.outputassert "completed: 1" in result.output, result.output# RUN 3: Run the CLI command again with a later timestamp to retire the job from the checkpoint# 5 minutes later is outside the eventual consistency window.with freeze_time(ISO_FREEZE_TIME_PLUS_5MIN):result = runner.invoke(main,["queue","sync-output",]+ storage_profile_options+ ["--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_' + storage_profile_in_message + '_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {(datetime.fromisoformat(ISO_FREEZE_TIME_PLUS_3MIN) - timedelta(seconds=EVENTUAL_CONSISTENCY_MAX_SECONDS)).astimezone().isoformat()}"in result.output), result.outputassert f"FINISHED TRACKING Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Job succeeded" in result.output, result.outputassert "inactive: 1" in result.output, result.output# RUN 4: Run the CLI command again with a later timestamp to see the job stay inactivewith freeze_time(ISO_FREEZE_TIME_PLUS_7MIN):result = runner.invoke(main,["queue","sync-output",]+ storage_profile_options+ ["--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_' + storage_profile_in_message + '_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {(datetime.fromisoformat(ISO_FREEZE_TIME_PLUS_5MIN) - timedelta(seconds=EVENTUAL_CONSISTENCY_MAX_SECONDS)).astimezone().isoformat()}"in result.output), result.output# Because this test didn't model any sessions and session actions, there is no session endedAt# timestamp, so no job needs to be further tracked as inactive in this case.assert "inactive: 0" in result.output, result.output
4
175
4
774
5
194
407
194
fresh_deadline_config,deadline_mock,checkpoint_dir,storage_profile_id
['storage_profile_in_message', 'mock_jobs', 'runner', 'result', 'storage_profile_options']
None
{"Assign": 21, "Expr": 1, "If": 3, "With": 4}
33
214
33
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif", "pytest.mark.parametrize"]
0
[]
The function (test_incremental_output_download_bootstrap_and_completion) defined within the public class called public.The function start at line 194 and ends at 407. It contains 175 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [194.0] and does not return any value. It declares 33.0 functions, and It has 33.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif", "pytest.mark.parametrize"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_storage_profile_path_mapping.mock_get_storage_profile_for_queue
def mock_get_storage_profile_for_queue(farmId: str, queueId: str, storageProfileId: str):assert farmId == MOCK_FARM_IDassert queueId == MOCK_QUEUE_IDif storageProfileId == MOCK_STORAGE_PROFILE_ID:return {"storageProfileId": MOCK_STORAGE_PROFILE_ID,"displayName": "Mock-Storage-Profile-For-Job","osFamily": "MACOS","fileSystemLocations": [{"name": "Location1", "path": "/Volumes/loc1", "type": "LOCAL"},{"name": "Location2", "path": "/Home/user", "type": "LOCAL"},],}else:return {"storageProfileId": MOCK_STORAGE_PROFILE_ID_LOCAL,"displayName": "Mock-Storage-Profile-For-Local","osFamily": StorageProfileOperatingSystemFamily.get_host_os_family().value.upper(),"fileSystemLocations": [{"name": "Location1", "path": str(tmp_path / "Location1"), "type": "LOCAL"},{"name": "Location2", "path": str(tmp_path / "Location2"), "type": "LOCAL"},],}
2
23
3
146
0
441
463
441
null
[]
None
null
0
0
0
null
0
null
The function (test_incremental_output_download_storage_profile_path_mapping.mock_get_storage_profile_for_queue) defined within the public class called public.The function start at line 441 and ends at 463. It contains 23 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [441.0] and does not return any value..
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_storage_profile_path_mapping
def test_incremental_output_download_storage_profile_path_mapping(fresh_deadline_config,tmp_path,deadline_mock,checkpoint_dir,):"""Test a new job with a different storage profile on the job thanconfigured locally so as to get some path mapping rules."""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}mock_jobs[0]["storageProfileId"] = MOCK_STORAGE_PROFILE_IDdel mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# Mock enough of get_storage_profile_for_queue two return two for mapping between themdef mock_get_storage_profile_for_queue(farmId: str, queueId: str, storageProfileId: str):assert farmId == MOCK_FARM_IDassert queueId == MOCK_QUEUE_IDif storageProfileId == MOCK_STORAGE_PROFILE_ID:return {"storageProfileId": MOCK_STORAGE_PROFILE_ID,"displayName": "Mock-Storage-Profile-For-Job","osFamily": "MACOS","fileSystemLocations": [{"name": "Location1", "path": "/Volumes/loc1", "type": "LOCAL"},{"name": "Location2", "path": "/Home/user", "type": "LOCAL"},],}else:return {"storageProfileId": MOCK_STORAGE_PROFILE_ID_LOCAL,"displayName": "Mock-Storage-Profile-For-Local","osFamily": StorageProfileOperatingSystemFamily.get_host_os_family().value.upper(),"fileSystemLocations": [{"name": "Location1", "path": str(tmp_path / "Location1"), "type": "LOCAL"},{"name": "Location2", "path": str(tmp_path / "Location2"), "type": "LOCAL"},],}deadline_mock.get_storage_profile_for_queue = mock_get_storage_profile_for_queue# Mock list_sessions to return one sessiondeadline_mock.list_sessions.return_value = {"sessions": [{"sessionId": MOCK_SESSION_ID,"fleetId": MOCK_FLEET_ID,"workerId": MOCK_WORKER_ID,"startedAt": "2025-08-06T00:15:45.712000+00:00","lifecycleStatus": "STARTED",}]}# Mock list_session_actions to return one task run session actiondeadline_mock.list_session_actions.return_value = {"sessionActions": [{"sessionActionId": MOCK_SESSION_ACTION_ID_1,"status": "SUCCEEDED","startedAt": "2025-08-06T00:20:58.454000+00:00","endedAt": "2025-08-06T00:20:59.992000+00:00","progressPercent": 100.0,"definition": {"taskRun": {"taskId": "task-b1764261dff54214aace3932bde8ae7e-0","stepId": "step-b1764261dff54214aace3932bde8ae7e",}},# This test doesn't go into the S3 object layer, so the manifests list is empty."manifests": [],},{"sessionActionId": MOCK_SESSION_ACTION_ID_2,"status": "RUNNING","startedAt": "2025-08-06T00:20:59.997000+00:00","progressPercent": 20.0,"definition": {"taskRun": {"taskId": "task-b1764261dff54214aace3932bde8ae7e-1","stepId": "step-b1764261dff54214aace3932bde8ae7e",}},},]}# RUN 1: Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--storage-profile-id",MOCK_STORAGE_PROFILE_ID_LOCAL,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that both storage profiles were retrieved for local and the jobassert (f"Local storage profile is Mock-Storage-Profile-For-Local ({MOCK_STORAGE_PROFILE_ID_LOCAL})"in result.output), result.outputassert ("0 download candidate jobs have the same storage profile and will be downloaded to their original specified paths"in result.output), result.outputassert (f"Path mapping rules for 1 download candidate jobs with storage profile Mock-Storage-Profile-For-Job ({MOCK_STORAGE_PROFILE_ID})"in result.output), result.outputassert "job storage profile: Mock-Storage-Profile-For-Job (MACOS)" in result.output, (result.output)assert (f"local storage profile: Mock-Storage-Profile-For-Local ({StorageProfileOperatingSystemFamily.get_host_os_family().value.upper()})"in result.output), result.outputassert "- from: /Volumes/loc1" in result.output, result.outputassert f" to: {tmp_path / 'Location1'}" in result.output, result.outputassert "- from: /Home/user" in result.output, result.outputassert f"to: {tmp_path / 'Location2'}" in result.output, result.output# Assert that it warned about the lack of outputsassert (f"WARNING: Job Mock Job ({MOCK_JOB_ID}) ran 1 / 1 session actions with no output."in result.output), result.outputassert ("This may indicate steps in the job that strictly perform validation or save results elsewhere like a shared file system or S3."in result.output), result.output
1
116
4
460
3
413
566
413
fresh_deadline_config,tmp_path,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs']
Returns
{"Assign": 14, "Expr": 1, "If": 1, "Return": 2, "With": 1}
13
154
13
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "value.upper", "StorageProfileOperatingSystemFamily.get_host_os_family", "str", "str", "CliRunner", "freeze_time", "runner.invoke", "value.upper", "StorageProfileOperatingSystemFamily.get_host_os_family", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_storage_profile_path_mapping) defined within the public class called public.The function start at line 413 and ends at 566. It contains 116 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [413.0], and this function return a value. It declares 13.0 functions, and It has 13.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "value.upper", "StorageProfileOperatingSystemFamily.get_host_os_family", "str", "str", "CliRunner", "freeze_time", "runner.invoke", "value.upper", "StorageProfileOperatingSystemFamily.get_host_os_family", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_bootstrap_retire_job_without_attachments
def test_incremental_output_download_bootstrap_retire_job_without_attachments(fresh_deadline_config, deadline_mock, checkpoint_dir):"""Test a new job through bootstrap and completion over two incremental download commands."""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}del mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 0.0 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 1 / 2" in result.output, result.outputassert "not using job attachments: 1" in result.output, result.output# Edit the mock job to complete the taskmock_jobs[0]["taskRunStatus"] = "SUCCEEDED"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 2,"READY": 0,}mock_jobs[0]["endedAt"] = datetime.fromisoformat(ISO_FREEZE_TIME)# RUN 2: Run the CLI command again after the job has all tasks completed# 3 minutes later is after the consistency window, so that the call after this# sees the job being retired.with freeze_time(ISO_FREEZE_TIME_PLUS_3MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert "not using job attachments: 1" in result.output, result.output# RUN 3: Run the CLI command again with a later timestamp to retire the job from the checkpoint# 5 minutes later is outside the eventual consistency window.with freeze_time(ISO_FREEZE_TIME_PLUS_5MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {(datetime.fromisoformat(ISO_FREEZE_TIME_PLUS_3MIN) - timedelta(seconds=EVENTUAL_CONSISTENCY_MAX_SECONDS)).astimezone().isoformat()}"in result.output), result.outputassert "inactive: 1" in result.output, result.output
1
104
3
466
3
572
702
572
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs']
None
{"Assign": 14, "Expr": 1, "With": 3}
25
131
25
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_bootstrap_retire_job_without_attachments) defined within the public class called public.The function start at line 572 and ends at 702. It contains 104 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [572.0] and does not return any value. It declares 25.0 functions, and It has 25.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_job_unchanged
def test_incremental_output_download_job_unchanged(fresh_deadline_config, deadline_mock, checkpoint_dir):"""Test a new job through bootstrap and an 'UNCHANGED' message."""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}del mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 0.0 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 1 / 2" in result.output, result.outputassert "added: 1" in result.output, result.output# RUN 2: Run the CLI command again to see that the job is unchangedwith freeze_time(ISO_FREEZE_TIME_PLUS_3MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"UNCHANGED Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "unchanged: 1" in result.output, result.output
1
78
3
368
3
708
800
708
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs']
None
{"Assign": 11, "Expr": 1, "With": 2}
17
93
17
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_job_unchanged) defined within the public class called public.The function start at line 708 and ends at 800. It contains 78 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [708.0] and does not return any value. It declares 17.0 functions, and It has 17.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_job_canceled
def test_incremental_output_download_job_canceled(fresh_deadline_config, deadline_mock, checkpoint_dir):"""Test a new job through bootstrap and cancelation before it's complete"""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}del mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 0.0 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 1 / 2" in result.output, result.outputassert "added: 1" in result.output, result.output# RUN 2: Run the CLI command again to see that the job is canceledmock_jobs[0]["taskRunStatus"] = "CANCELED"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"CANCELED": 1,}with freeze_time(ISO_FREEZE_TIME_PLUS_3MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"FINISHED TRACKING Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert ("Job is not a download candidate anymore (likely suspended, canceled or failed)"in result.output), result.outputassert "inactive: 1" in result.output, result.output
1
87
3
407
3
806
907
806
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs']
None
{"Assign": 13, "Expr": 1, "With": 2}
17
102
17
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_job_canceled) defined within the public class called public.The function start at line 806 and ends at 907. It contains 87 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [806.0] and does not return any value. It declares 17.0 functions, and It has 17.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_job_completed_then_requeued
def test_incremental_output_download_job_completed_then_requeued(fresh_deadline_config, deadline_mock, checkpoint_dir):"""Test a new job through bootstrap, retirement, then requeue."""iso_freeze_time = datetime.fromisoformat(ISO_FREEZE_TIME)mock_jobs = create_fake_job_list(1, iso_freeze_time - timedelta(minutes=5), iso_freeze_time)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "SUCCEEDED"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 2,"READY": 0,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}mock_jobs[0]["endedAt"] = iso_freeze_time - timedelta(minutes=3)deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operation# We've set up the job and timestamps so it bootstraps as completedrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,"--bootstrap-lookback-minutes","4.5",],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 4.5 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {(iso_freeze_time - timedelta(minutes=4.5)).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 2 / 2" in result.output, result.outputassert "completed: 1" in result.output, result.output# RUN 2: Run the CLI command again to see that the job becomes inactivewith freeze_time(ISO_FREEZE_TIME_PLUS_5MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {(iso_freeze_time - timedelta(seconds=EVENTUAL_CONSISTENCY_MAX_SECONDS)).astimezone().isoformat()}"in result.output), result.outputassert "inactive: 1" in result.output, result.output# RUN 3: Run the CLI command again after requeuing tasksmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}del mock_jobs[0]["endedAt"]with freeze_time(ISO_FREEZE_TIME_PLUS_5MIN):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about loading the checkpoint and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint found" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Continuing from: {(datetime.fromisoformat(ISO_FREEZE_TIME_PLUS_5MIN) - timedelta(seconds=EVENTUAL_CONSISTENCY_MAX_SECONDS)).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Succeeded tasks: 1 / 2" in result.output, result.outputassert "added: 1" in result.output, result.output
1
115
3
546
4
913
1,050
913
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs', 'iso_freeze_time']
None
{"Assign": 16, "Expr": 1, "With": 3}
27
138
27
["datetime.fromisoformat", "create_fake_job_list", "timedelta", "timedelta", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_job_completed_then_requeued) defined within the public class called public.The function start at line 913 and ends at 1050. It contains 115 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [913.0] and does not return any value. It declares 27.0 functions, and It has 27.0 functions called inside which are ["datetime.fromisoformat", "create_fake_job_list", "timedelta", "timedelta", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "timedelta", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "timedelta", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_dry_run
def test_incremental_output_download_dry_run(fresh_deadline_config, deadline_mock, checkpoint_dir):"""Test a new job through bootstrap, completion, and retirement."""mock_jobs = create_fake_job_list(1)mock_jobs[0]["name"] = "Mock Job"mock_jobs[0]["jobId"] = MOCK_JOB_IDmock_jobs[0]["taskRunStatus"] = "READY"mock_jobs[0]["taskRunStatusCounts"] = {"SUCCEEDED": 1,"READY": 1,}mock_jobs[0]["attachments"] = {"manifests": [{"rootPath": "/", "rootPathFormat": "posix", "outputRelativeDirectories": ["."]}],"fileSystem": "VIRTUAL",}del mock_jobs[0]["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, mock_jobs)# RUN 1: Run the CLI command once to bootstrap the operationrunner = CliRunner()with freeze_time(ISO_FREEZE_TIME):result = runner.invoke(main,["queue","sync-output","--ignore-storage-profiles","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--checkpoint-dir",checkpoint_dir,"--dry-run",],)# Assert the command executed successfullyassert result.exit_code == 0, result.output# Assert that the output contained information about the bootstrapping and the mocked resourcesassert "Started incremental download for queue: Mock Queue" in result.output, result.outputassert (f"Checkpoint: {os.path.join(checkpoint_dir, MOCK_QUEUE_ID + '_ignore-storage-profiles_download_checkpoint.json')}"in result.output), result.outputassert "Checkpoint not found, lookback is 0.0 minutes" in result.output, result.output# Need to convert the freeze time to the local time zone for this print assertionassert (f"Initializing from: {datetime.fromisoformat(ISO_FREEZE_TIME).astimezone().isoformat()}"in result.output), result.outputassert f"NEW Job: Mock Job ({MOCK_JOB_ID})" in result.output, result.outputassert "Skipping downloads due to DRY RUN" in result.output, result.outputassert ("Summary of DRY RUN for incremental output download (no files were downloaded to the file system):"in result.output), result.outputassert "This is a DRY RUN so the checkpoint was not saved" in result.output, result.output
1
53
3
269
3
1,056
1,116
1,056
fresh_deadline_config,deadline_mock,checkpoint_dir
['result', 'runner', 'mock_jobs']
None
{"Assign": 10, "Expr": 1, "With": 1}
11
61
11
["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_dry_run) defined within the public class called public.The function start at line 1056 and ends at 1116. It contains 53 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1056.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["create_fake_job_list", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "os.path.join", "isoformat", "astimezone", "datetime.fromisoformat", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
public
public
0
0
test_incremental_output_download_stats_telemetry
def test_incremental_output_download_stats_telemetry(fresh_deadline_config,deadline_mock,checkpoint_dir,deadline_telemetry_client_mock,):"""Verifies the telemetry event for statistics matches the expected format"""mock_job = create_fake_job_list(1)[0]mock_job.update({"name": "Mock Job","jobId": MOCK_JOB_ID,"taskRunStatus": "READY","taskRunStatusCounts": {"SUCCEEDED": 1},"storageProfileId": MOCK_STORAGE_PROFILE_ID,"attachments": {"manifests": [{"rootPath": "/", "rootPathFormat": "posix"}],"fileSystem": "VIRTUAL",},})del mock_job["endedAt"]deadline_mock.search_jobs = mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, [mock_job])deadline_mock.get_job = mock_get_job_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, [mock_job])runner = CliRunner()with freeze_time(ISO_FREEZE_TIME):runner.invoke(main,["queue","sync-output","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--storage-profile-id",MOCK_STORAGE_PROFILE_ID,"--checkpoint-dir",checkpoint_dir,],)deadline_telemetry_client_mock().record_event.assert_called_once_with(event_type="com.amazon.rum.deadline.queue_sync_output_stats",event_details={# All latencies will be zero due to freeze_time()"latencies": {"_get_download_candidate_jobs": 0,"_categorize_jobs_in_checkpoint": 0,"_get_job_sessions": 0,"_update_checkpoint_jobs_list": 0,"_download_all_manifests_with_absolute_paths": 0,"download": 0,"path_mapping": 0,},"dry_run": False,"downloaded_session_actions": 0,"downloaded_files": 0,"downloaded_bytes": 0,"jobs_with_downloads": {"completed": 0, "added": 1, "updated": 0},"jobs_without_downloads": {"not_using_job_attachments": 0,"missing_storage_profile": 0,"unchanged": 0,"inactive": 0,},"unmapped_paths": 0,},)
1
66
4
258
2
1,122
1,191
1,122
fresh_deadline_config,deadline_mock,checkpoint_dir,deadline_telemetry_client_mock
['runner', 'mock_job']
None
{"Assign": 4, "Expr": 4, "With": 1}
10
70
10
["create_fake_job_list", "mock_job.update", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "record_event.assert_called_once_with", "deadline_telemetry_client_mock", "pytest.mark.skipif"]
0
[]
The function (test_incremental_output_download_stats_telemetry) defined within the public class called public.The function start at line 1122 and ends at 1191. It contains 66 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [1122.0] and does not return any value. It declares 10.0 functions, and It has 10.0 functions called inside which are ["create_fake_job_list", "mock_job.update", "mock_search_jobs_for_set", "mock_get_job_for_set", "CliRunner", "freeze_time", "runner.invoke", "record_event.assert_called_once_with", "deadline_telemetry_client_mock", "pytest.mark.skipif"].
aws-deadline_deadline-cloud
TestSigIntHAndler
public
0
0
test_singleton_instance
def test_singleton_instance(self):"""Ensures that only one instance of SigIntHandler can exist"""handler1 = SigIntHandler()handler2 = SigIntHandler()assert handler1 is handler2
1
4
1
20
0
7
11
7
self
[]
None
{"Assign": 2, "Expr": 1}
2
5
2
["SigIntHandler", "SigIntHandler"]
0
[]
The function (test_singleton_instance) defined within the public class called TestSigIntHAndler.The function start at line 7 and ends at 11. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["SigIntHandler", "SigIntHandler"].
aws-deadline_deadline-cloud
public
public
0
0
add_mocks_for_worker_list
def add_mocks_for_worker_list(deadline_mock):"""Adds mock return values to the deadline_mock for sharing acrossthe different 'deadline worker list' tests."""deadline_mock.search_workers.return_value = {"totalResults": 2,"workers": [{"workerId": "worker-1234567890abcdef1234567890abcdef","status": "RUNNING","createdAt": datetime.fromisoformat("2024-01-01T10:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,"hostProperties": {"ipAddresses": {"ipV4Addresses": ["192.168.1.100"], "ipV6Addresses": []},"hostName": "worker-host-001","ec2InstanceArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-1234567890abcdef0","ec2InstanceType": "m5.large",},"log": {"logDriver": "awslogs","options": {"awslogs-group": "/aws/deadline/worker","awslogs-region": "us-west-2",},},"createdBy": "arn:aws:sts::123456789012:assumed-role/Admin/user","updatedAt": datetime.fromisoformat("2024-01-01T12:00:00+00:00"),"updatedBy": "arn:aws:sts::123456789012:assumed-role/Admin/user",},{"workerId": "worker-abcdef1234567890abcdef1234567890","status": "IDLE","createdAt": datetime.fromisoformat("2024-01-01T11:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,"hostProperties": {"ipAddresses": {"ipV4Addresses": ["192.168.1.101"], "ipV6Addresses": []},"hostName": "worker-host-002","ec2InstanceArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-abcdef1234567890a","ec2InstanceType": "m5.xlarge",},"log": {"logDriver": "awslogs","options": {"awslogs-group": "/aws/deadline/worker","awslogs-region": "us-west-2",},},"createdBy": "arn:aws:sts::123456789012:assumed-role/Admin/user","updatedAt": datetime.fromisoformat("2024-01-01T13:00:00+00:00"),"updatedBy": "arn:aws:sts::123456789012:assumed-role/Admin/user",},],}
1
52
1
221
0
20
75
20
deadline_mock
[]
None
{"Assign": 1, "Expr": 1}
4
56
4
["datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat"]
1
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_worker_py.test_cli_worker_list_success"]
The function (add_mocks_for_worker_list) defined within the public class called public.The function start at line 20 and ends at 75. It contains 52 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 4.0 functions, It has 4.0 functions called inside which are ["datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat"], It has 1.0 function calling this function which is ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_worker_py.test_cli_worker_list_success"].
aws-deadline_deadline-cloud
public
public
0
0
add_mocks_for_worker_get
def add_mocks_for_worker_get(deadline_mock):"""Adds mock return values to the deadline_mock for sharing acrossthe different 'deadline worker get' tests."""deadline_mock.get_worker.return_value = {"workerId": MOCK_WORKER_ID,"status": "RUNNING","createdAt": datetime.fromisoformat("2024-01-01T10:00:00+00:00"),"updatedAt": datetime.fromisoformat("2024-01-01T12:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,"hostProperties": {"ipAddresses": {"ipV4Addresses": ["192.168.1.100"], "ipV6Addresses": []},"hostName": "worker-host-001","ec2InstanceArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-1234567890abcdef0","ec2InstanceType": "m5.large",},"log": {"logDriver": "awslogs","options": {"awslogs-group": "/aws/deadline/worker", "awslogs-region": "us-west-2"},},"createdBy": "arn:aws:sts::123456789012:assumed-role/Admin/user","updatedBy": "arn:aws:sts::123456789012:assumed-role/Admin/user","ResponseMetadata": {"RequestId": "12345678-1234-1234-1234-123456789012","HTTPStatusCode": 200,"HTTPHeaders": {"date": "Mon, 01 Jan 2024 12:00:00 GMT","content-type": "application/x-amz-json-1.0",},"RetryAttempts": 0,},}
1
30
1
139
0
78
111
78
deadline_mock
[]
None
{"Assign": 1, "Expr": 1}
2
34
2
["datetime.fromisoformat", "datetime.fromisoformat"]
1
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_worker_py.test_cli_worker_get_success"]
The function (add_mocks_for_worker_get) defined within the public class called public.The function start at line 78 and ends at 111. It contains 30 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, It has 2.0 functions called inside which are ["datetime.fromisoformat", "datetime.fromisoformat"], It has 1.0 function calling this function which is ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_worker_py.test_cli_worker_get_success"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_success
def test_cli_worker_list_success(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' successfully lists workers in a fleet."""add_mocks_for_worker_list(deadline_mock)runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,],)# Verify the CLI output format matches expected YAML structure with unquoted datetime valuesexpected_output = """Displaying 2 of 2 workers starting at 0- workerId: worker-1234567890abcdef1234567890abcdefstatus: RUNNINGcreatedAt: 2024-01-01 10:00:00+00:00- workerId: worker-abcdef1234567890abcdef1234567890status: IDLEcreatedAt: 2024-01-01 11:00:00+00:00"""assert result.output == expected_outputassert result.exit_code == 0# Assert correct API call parameters (farmId, fleetIds, itemOffset=0, pageSize=5)deadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=[MOCK_FLEET_ID], itemOffset=0, pageSize=5)
1
29
2
80
3
114
151
114
fresh_deadline_config,deadline_mock
['expected_output', 'runner', 'result']
None
{"Assign": 3, "Expr": 3}
4
38
4
["add_mocks_for_worker_list", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_success) defined within the public class called public.The function start at line 114 and ends at 151. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [114.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["add_mocks_for_worker_list", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_pagination
def test_cli_worker_list_pagination(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' correctly handles custom page-size and item-offset parameters."""# Mock response for pagination test with custom parametersdeadline_mock.search_workers.return_value = {"totalResults": 50,"workers": [{"workerId": "worker-page2-item1-1234567890abcdef","status": "RUNNING","createdAt": datetime.fromisoformat("2024-01-01T10:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,},{"workerId": "worker-page2-item2-abcdef1234567890","status": "IDLE","createdAt": datetime.fromisoformat("2024-01-01T11:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,},{"workerId": "worker-page2-item3-fedcba0987654321","status": "STOPPING","createdAt": datetime.fromisoformat("2024-01-01T12:00:00+00:00"),"fleetId": MOCK_FLEET_ID,"farmId": MOCK_FARM_ID,},],}runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--page-size","3","--item-offset","10",],)# Verify pagination information is displayed correctly in CLI outputexpected_output = """Displaying 3 of 50 workers starting at 10- workerId: worker-page2-item1-1234567890abcdefstatus: RUNNINGcreatedAt: 2024-01-01 10:00:00+00:00- workerId: worker-page2-item2-abcdef1234567890status: IDLEcreatedAt: 2024-01-01 11:00:00+00:00- workerId: worker-page2-item3-fedcba0987654321status: STOPPINGcreatedAt: 2024-01-01 12:00:00+00:00"""assert result.output == expected_outputassert result.exit_code == 0# Test that API is called with correct pagination parametersdeadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=[MOCK_FLEET_ID], itemOffset=10, pageSize=3)
1
61
2
185
3
154
224
154
fresh_deadline_config,deadline_mock
['expected_output', 'runner', 'result']
None
{"Assign": 4, "Expr": 2}
6
71
6
["datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_pagination) defined within the public class called public.The function start at line 154 and ends at 224. It contains 61 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [154.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["datetime.fromisoformat", "datetime.fromisoformat", "datetime.fromisoformat", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_empty_results
def test_cli_worker_list_empty_results(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' handles empty worker list scenario appropriately."""# Mock response for empty resultsdeadline_mock.search_workers.return_value = {"totalResults": 0, "workers": []}runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--item-offset","5",],)# Verify appropriate messaging when no workers are foundexpected_output = """Displaying 0 of 0 workers starting at 5[]"""assert result.output == expected_outputassert result.exit_code == 0# Verify API call parametersdeadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=[MOCK_FLEET_ID], itemOffset=5, pageSize=5)
1
26
2
96
3
227
262
227
fresh_deadline_config,deadline_mock
['expected_output', 'runner', 'result']
None
{"Assign": 4, "Expr": 2}
3
36
3
["CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_empty_results) defined within the public class called public.The function start at line 227 and ends at 262. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [227.0] and does not return any value. It declares 3.0 functions, and It has 3.0 functions called inside which are ["CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_missing_fleet_id
def test_cli_worker_list_missing_fleet_id(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' displays usage message and exits with code 2 when required --fleet-id is missing."""runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,# Missing --fleet-id parameter],)# Verify Click displays usage message and exits with code 2assert "Error: Missing option '--fleet-id'." in result.outputassert result.exit_code == 2# Verify API was not called since validation faileddeadline_mock.search_workers.assert_not_called()
1
14
2
52
2
265
286
265
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 2, "Expr": 2}
3
22
3
["CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_not_called"]
0
[]
The function (test_cli_worker_list_missing_fleet_id) defined within the public class called public.The function start at line 265 and ends at 286. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [265.0] and does not return any value. It declares 3.0 functions, and It has 3.0 functions called inside which are ["CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_not_called"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_api_error
def test_cli_worker_list_api_error(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' handles AWS ClientError scenarios appropriately."""# Test incorrect fleet-id scenariodeadline_mock.search_workers.side_effect = ClientError(error_response={"Error": {"Code": "ValidationException","Message": "Fleet ID must match the pattern: ^fleet-[0-9a-f]{32}$",}},operation_name="SearchWorkers",)runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id","incorrect-fleet-id",],)# Verify DeadlineOperationError message appears in CLI outputassert "Failed to get Workers from Deadline:" in result.outputassert "Fleet ID must match the pattern" in result.outputassert result.exit_code != 0# Verify API was called with the incorrect parameter valuesdeadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=["incorrect-fleet-id"], itemOffset=0, pageSize=5)
1
28
2
109
2
289
325
289
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
37
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_api_error) defined within the public class called public.The function start at line 289 and ends at 325. It contains 28 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [289.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_api_error_network_timeout
def test_cli_worker_list_api_error_network_timeout(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' handles network timeout ClientError scenarios."""# Test network timeout scenariodeadline_mock.search_workers.side_effect = ClientError(error_response={"Error": {"Code": "RequestTimeout", "Message": "Request timed out"}},operation_name="SearchWorkers",)runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,],)# Verify DeadlineOperationError message appears in CLI outputassert "Failed to get Workers from Deadline:" in result.outputassert "Request timed out" in result.outputassert result.exit_code != 0# Verify API was calleddeadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=[MOCK_FLEET_ID], itemOffset=0, pageSize=5)
1
23
2
108
2
328
359
328
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
32
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_api_error_network_timeout) defined within the public class called public.The function start at line 328 and ends at 359. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [328.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_list_api_error_throttling
def test_cli_worker_list_api_error_throttling(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker list' handles throttling ClientError scenarios."""# Test throttling scenariodeadline_mock.search_workers.side_effect = ClientError(error_response={"Error": {"Code": "ThrottlingException", "Message": "Rate exceeded"}},operation_name="SearchWorkers",)runner = CliRunner()result = runner.invoke(main,["worker","list","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,],)# Verify DeadlineOperationError message appears in CLI outputassert "Failed to get Workers from Deadline:" in result.outputassert "Rate exceeded" in result.outputassert result.exit_code != 0# Verify API was calleddeadline_mock.search_workers.assert_called_once_with(farmId=MOCK_FARM_ID, fleetIds=[MOCK_FLEET_ID], itemOffset=0, pageSize=5)
1
23
2
108
2
362
393
362
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
32
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"]
0
[]
The function (test_cli_worker_list_api_error_throttling) defined within the public class called public.The function start at line 362 and ends at 393. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [362.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.search_workers.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_success
def test_cli_worker_get_success(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' successfully retrieves and displays complete worker details."""add_mocks_for_worker_get(deadline_mock)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id",MOCK_WORKER_ID,],)# Verify complete worker details are displayed in YAML format# ResponseMetadata should be removed from output as expectedexpected_output = f"""workerId: {MOCK_WORKER_ID}status: RUNNINGcreatedAt: 2024-01-01 10:00:00+00:00updatedAt: 2024-01-01 12:00:00+00:00fleetId: {MOCK_FLEET_ID}farmId: {MOCK_FARM_ID}hostProperties:ipAddresses:ipV4Addresses:- 192.168.1.100ipV6Addresses: []hostName: worker-host-001ec2InstanceArn: arn:aws:ec2:us-west-2:123456789012:instance/i-1234567890abcdef0ec2InstanceType: m5.largelog:logDriver: awslogsoptions:awslogs-group: /aws/deadline/workerawslogs-region: us-west-2createdBy: arn:aws:sts::123456789012:assumed-role/Admin/userupdatedBy: arn:aws:sts::123456789012:assumed-role/Admin/user"""assert result.output == expected_outputassert result.exit_code == 0# Verify correct API call parameters (farmId, fleetId, workerId)deadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID, fleetId=MOCK_FLEET_ID, workerId=MOCK_WORKER_ID)# Verify that ResponseMetadata is not present in the outputassert "ResponseMetadata" not in result.outputassert "RequestId" not in result.outputassert "HTTPStatusCode" not in result.output# Test that datetime fields are displayed as unquoted valuesassert "createdAt: 2024-01-01 10:00:00+00:00" in result.outputassert "updatedAt: 2024-01-01 12:00:00+00:00" in result.output# Ensure they are not quotedassert "'2024-01-01 10:00:00+00:00'" not in result.outputassert '"2024-01-01 10:00:00+00:00"' not in result.output
1
28
2
126
3
396
461
396
fresh_deadline_config,deadline_mock
['expected_output', 'runner', 'result']
None
{"Assign": 3, "Expr": 3}
4
66
4
["add_mocks_for_worker_get", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_success) defined within the public class called public.The function start at line 396 and ends at 461. It contains 28 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [396.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["add_mocks_for_worker_get", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_missing_required_options
def test_cli_worker_get_missing_required_options(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' displays appropriate error messages and exit codes for missing required parameters."""runner = CliRunner()# Test missing --fleet-idresult = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--worker-id",MOCK_WORKER_ID,# Missing --fleet-id parameter],)# Verify appropriate error messages and exit codes for missing parametersassert "Error: Missing option '--fleet-id'." in result.outputassert result.exit_code == 2# Verify API was not called since validation faileddeadline_mock.get_worker.assert_not_called()# Test missing --worker-idresult = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,# Missing --worker-id parameter],)# Verify appropriate error messages and exit codes for missing parametersassert "Error: Missing option '--worker-id'." in result.outputassert result.exit_code == 2# Verify API was not called since validation faileddeadline_mock.get_worker.assert_not_called()# Test missing both --fleet-id and --worker-idresult = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,# Missing both --fleet-id and --worker-id parameters],)# Verify appropriate error messages and exit codes for missing parameters# Click will report the first missing required optionassert "Error: Missing option" in result.outputassert result.exit_code == 2# Verify API was not called since validation faileddeadline_mock.get_worker.assert_not_called()
1
42
2
138
2
464
530
464
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 4, "Expr": 4}
7
67
7
["CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_not_called", "runner.invoke", "deadline_mock.get_worker.assert_not_called", "runner.invoke", "deadline_mock.get_worker.assert_not_called"]
0
[]
The function (test_cli_worker_get_missing_required_options) defined within the public class called public.The function start at line 464 and ends at 530. It contains 42 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [464.0] and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_not_called", "runner.invoke", "deadline_mock.get_worker.assert_not_called", "runner.invoke", "deadline_mock.get_worker.assert_not_called"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_api_error
def test_cli_worker_get_api_error(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' handles AWS ClientError scenarios appropriately."""# Test incorrect worker-id scenario with ResourceNotFoundExceptiondeadline_mock.get_worker.side_effect = ClientError(error_response={"Error": {"Code": "ResourceNotFoundException", "Message": "Worker not found"}},operation_name="GetWorker",)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id","worker-incorrect1234567890abcdef1234567890",],)# Mock ClientError for ResourceNotFoundException and verify proper error handling# The @_handle_error decorator shows the full exception tracebackassert "The AWS Deadline Cloud CLI encountered the following exception:" in result.outputassert "ResourceNotFoundException" in result.outputassert "Worker not found" in result.outputassert result.exit_code == 1# Verify API was called with the incorrect parameter valuesdeadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID,fleetId=MOCK_FLEET_ID,workerId="worker-incorrect1234567890abcdef1234567890",)
1
30
2
113
2
533
572
533
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
40
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_api_error) defined within the public class called public.The function start at line 533 and ends at 572. It contains 30 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [533.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_api_error_validation_exception
def test_cli_worker_get_api_error_validation_exception(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' handles ValidationException for incorrect worker-id format."""# Test incorrect worker-id format scenariodeadline_mock.get_worker.side_effect = ClientError(error_response={"Error": {"Code": "ValidationException","Message": "Worker ID must match the pattern: ^worker-[0-9a-f]{32}$",}},operation_name="GetWorker",)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id","incorrect-worker-id",],)# Verify ValidationException is handled and displays regex validation error# The @_handle_error decorator shows the full exception tracebackassert "The AWS Deadline Cloud CLI encountered the following exception:" in result.outputassert "ValidationException" in result.outputassert "Worker ID must match the pattern" in result.outputassert result.exit_code == 1# Verify API was called with the incorrect parameter valuesdeadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID, fleetId=MOCK_FLEET_ID, workerId="incorrect-worker-id")
1
31
2
113
2
575
615
575
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
41
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_api_error_validation_exception) defined within the public class called public.The function start at line 575 and ends at 615. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [575.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_api_error_network_timeout
def test_cli_worker_get_api_error_network_timeout(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' handles network timeout ClientError scenarios."""# Test network timeout scenariodeadline_mock.get_worker.side_effect = ClientError(error_response={"Error": {"Code": "RequestTimeout", "Message": "Request timed out"}},operation_name="GetWorker",)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id",MOCK_WORKER_ID,],)# Test network and service error scenarios# The @_handle_error decorator shows the full exception tracebackassert "The AWS Deadline Cloud CLI encountered the following exception:" in result.outputassert "RequestTimeout" in result.outputassert "Request timed out" in result.outputassert result.exit_code == 1# Verify API was calleddeadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID, fleetId=MOCK_FLEET_ID, workerId=MOCK_WORKER_ID)
1
26
2
112
2
618
653
618
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
36
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_api_error_network_timeout) defined within the public class called public.The function start at line 618 and ends at 653. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [618.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_api_error_throttling
def test_cli_worker_get_api_error_throttling(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' handles throttling ClientError scenarios."""# Test throttling scenariodeadline_mock.get_worker.side_effect = ClientError(error_response={"Error": {"Code": "ThrottlingException", "Message": "Rate exceeded"}},operation_name="GetWorker",)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id",MOCK_WORKER_ID,],)# Test network and service error scenarios# The @_handle_error decorator shows the full exception tracebackassert "The AWS Deadline Cloud CLI encountered the following exception:" in result.outputassert "ThrottlingException" in result.outputassert "Rate exceeded" in result.outputassert result.exit_code == 1# Verify API was calleddeadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID, fleetId=MOCK_FLEET_ID, workerId=MOCK_WORKER_ID)
1
26
2
112
2
656
691
656
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
36
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_api_error_throttling) defined within the public class called public.The function start at line 656 and ends at 691. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [656.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_cli_worker_get_api_error_service_unavailable
def test_cli_worker_get_api_error_service_unavailable(fresh_deadline_config, deadline_mock):"""Tests that 'deadline worker get' handles service unavailable ClientError scenarios."""# Test service unavailable scenariodeadline_mock.get_worker.side_effect = ClientError(error_response={"Error": {"Code": "ServiceUnavailableException","Message": "Service temporarily unavailable",}},operation_name="GetWorker",)runner = CliRunner()result = runner.invoke(main,["worker","get","--farm-id",MOCK_FARM_ID,"--fleet-id",MOCK_FLEET_ID,"--worker-id",MOCK_WORKER_ID,],)# Test network and service error scenarios# The @_handle_error decorator shows the full exception tracebackassert "The AWS Deadline Cloud CLI encountered the following exception:" in result.outputassert "ServiceUnavailableException" in result.outputassert "Service temporarily unavailable" in result.outputassert result.exit_code == 1# Verify API was calleddeadline_mock.get_worker.assert_called_once_with(farmId=MOCK_FARM_ID, fleetId=MOCK_FLEET_ID, workerId=MOCK_WORKER_ID)
1
31
2
113
2
694
734
694
fresh_deadline_config,deadline_mock
['runner', 'result']
None
{"Assign": 3, "Expr": 2}
4
41
4
["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"]
0
[]
The function (test_cli_worker_get_api_error_service_unavailable) defined within the public class called public.The function start at line 694 and ends at 734. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [694.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "deadline_mock.get_worker.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
temp_dir
def temp_dir():"""Fixture to provide a temporary directory that is cleaned up after tests."""with tempfile.TemporaryDirectory() as tmpdir:yield tmpdir
1
3
0
16
0
24
29
24
[]
None
{"Expr": 2, "With": 1}
1
6
1
["tempfile.TemporaryDirectory"]
1
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.3924769_jaraco_zipp.tests.test_path_py.TestPath.zipfile_ondisk"]
The function (temp_dir) defined within the public class called public.The function start at line 24 and ends at 29. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, It has 1.0 function called inside which is ["tempfile.TemporaryDirectory"], It has 1.0 function calling this function which is ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.3924769_jaraco_zipp.tests.test_path_py.TestPath.zipfile_ondisk"].
aws-deadline_deadline-cloud
public
public
0
0
temp_pid_lock_file
def temp_pid_lock_file(temp_dir):"""Fixture to provide a pid file lock name in the temporary directory"""yield os.path.join(temp_dir, "pid_lock_file.pid")
1
2
1
17
0
33
37
33
temp_dir
[]
None
{"Expr": 2}
1
5
1
["os.path.join"]
0
[]
The function (temp_pid_lock_file) defined within the public class called public.The function start at line 33 and ends at 37. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declare 1.0 function, and It has 1.0 function called inside which is ["os.path.join"].
aws-deadline_deadline-cloud
public
public
0
0
test_pidlock_acquire_and_release
def test_pidlock_acquire_and_release(temp_pid_lock_file):"""Tests normal pidlock acquisition/release."""# Lock file does not exist before acquiring the lockassert not os.path.exists(temp_pid_lock_file)_try_acquire_pid_lock(temp_pid_lock_file)# Lock file exists after acquiring the lockassert os.path.exists(temp_pid_lock_file)# Lock file contains the current process idwith open(temp_pid_lock_file) as fh:assert int(fh.read()) == os.getpid()_release_pid_lock(temp_pid_lock_file)# Lock file is removed when releasing the lockassert not os.path.exists(temp_pid_lock_file)
1
8
1
66
0
40
59
40
temp_pid_lock_file
[]
None
{"Expr": 3, "With": 1}
9
20
9
["os.path.exists", "_try_acquire_pid_lock", "os.path.exists", "open", "int", "fh.read", "os.getpid", "_release_pid_lock", "os.path.exists"]
0
[]
The function (test_pidlock_acquire_and_release) defined within the public class called public.The function start at line 40 and ends at 59. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["os.path.exists", "_try_acquire_pid_lock", "os.path.exists", "open", "int", "fh.read", "os.getpid", "_release_pid_lock", "os.path.exists"].
aws-deadline_deadline-cloud
public
public
0
0
test_pidlock_contextmanager_acquire_and_release
def test_pidlock_contextmanager_acquire_and_release(temp_pid_lock_file):"""Tests normal pidlock acquisition/release with the context manager."""# Lock file does not exist before acquiring the lockassert not os.path.exists(temp_pid_lock_file)with PidFileLock(temp_pid_lock_file):# Lock file exists after acquiring the lockassert os.path.exists(temp_pid_lock_file)# Lock file contains the current process idwith open(temp_pid_lock_file) as fh:assert fh.read() == str(os.getpid())# Lock file is removed when releasing the lockassert not os.path.exists(temp_pid_lock_file)
1
7
1
64
0
62
78
62
temp_pid_lock_file
[]
None
{"Expr": 1, "With": 2}
8
17
8
["os.path.exists", "PidFileLock", "os.path.exists", "open", "fh.read", "str", "os.getpid", "os.path.exists"]
0
[]
The function (test_pidlock_contextmanager_acquire_and_release) defined within the public class called public.The function start at line 62 and ends at 78. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["os.path.exists", "PidFileLock", "os.path.exists", "open", "fh.read", "str", "os.getpid", "os.path.exists"].
aws-deadline_deadline-cloud
public
public
0
0
test_check_pid_lock_when_process_not_running
def test_check_pid_lock_when_process_not_running(temp_pid_lock_file):"""Tests when PID file exists but process is not running.This is the case when a run was terminated mid-way causing a stale pid file to exist."""# Write a PID that doesn't exist to the lock filewith open(temp_pid_lock_file, "w") as fh:fh.write(str(FAKE_PID))# Patch the logger object to confirm it writes a warning message about the lock filewith patch.object(_pid_file_lock, "logger") as logger_mock:_try_acquire_pid_lock(temp_pid_lock_file)# The function should have logged about deleting the lock fileassert logger_mock.warning.call_count == 1warning_message = logger_mock.warning.call_args.args[0]assert (f"Process with pid {FAKE_PID} is not running. Deleted pid lock file." in warning_message)# The lock file should now contain the current pidwith open(temp_pid_lock_file) as fh:assert fh.read() == str(os.getpid())
1
12
1
91
1
81
103
81
temp_pid_lock_file
['warning_message']
None
{"Assign": 1, "Expr": 3, "With": 3}
9
23
9
["open", "fh.write", "str", "patch.object", "_try_acquire_pid_lock", "open", "fh.read", "str", "os.getpid"]
0
[]
The function (test_check_pid_lock_when_process_not_running) defined within the public class called public.The function start at line 81 and ends at 103. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["open", "fh.write", "str", "patch.object", "_try_acquire_pid_lock", "open", "fh.read", "str", "os.getpid"].
aws-deadline_deadline-cloud
public
public
0
0
test_check_pid_lock_with_corrupt_pidfile
def test_check_pid_lock_with_corrupt_pidfile(temp_pid_lock_file):"""Tests when PID file exists and contains corrupted data.In this case it should delete the file and log a warning."""# Write a PID that doesn't exist to the lock filewith open(temp_pid_lock_file, "w") as fh:fh.write("bad_data")# Patch the logger object to confirm it writes a warning message about the lock filewith patch.object(_pid_file_lock, "logger") as logger_mock:_try_acquire_pid_lock(temp_pid_lock_file)# The function should have logged about deleting the lock fileassert logger_mock.warning.call_count == 1warning_message = logger_mock.warning.call_args.args[0]assert "Pid lock file contains incorrect data. Deleted pid lock file." in warning_message# The lock file should now contain the current pidwith open(temp_pid_lock_file) as fh:assert fh.read() == str(os.getpid())
1
10
1
85
1
106
126
106
temp_pid_lock_file
['warning_message']
None
{"Assign": 1, "Expr": 3, "With": 3}
8
21
8
["open", "fh.write", "patch.object", "_try_acquire_pid_lock", "open", "fh.read", "str", "os.getpid"]
0
[]
The function (test_check_pid_lock_with_corrupt_pidfile) defined within the public class called public.The function start at line 106 and ends at 126. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["open", "fh.write", "patch.object", "_try_acquire_pid_lock", "open", "fh.read", "str", "os.getpid"].
aws-deadline_deadline-cloud
public
public
0
0
test_check_pid_lock_when_process_running.FAKE_PID_exists
def FAKE_PID_exists(pid):return pid == FAKE_PID
1
2
1
9
0
139
140
139
null
[]
None
null
0
0
0
null
0
null
The function (test_check_pid_lock_when_process_running.FAKE_PID_exists) defined within the public class called public.The function start at line 139 and ends at 140. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
aws-deadline_deadline-cloud
public
public
0
0
test_check_pid_lock_when_process_running
def test_check_pid_lock_when_process_running(temp_pid_lock_file):"""Tests when PID file exists and process is running.This is the case when a process is already holding the lock."""# Write a PID that doesn't exist to the lock file (value is larger than PIDs are typically)with open(temp_pid_lock_file, "w") as fh:fh.write(str(FAKE_PID))# Patch psutil.pid_exists to return that the mock_pid existsdef FAKE_PID_exists(pid):return pid == FAKE_PIDwith patch.object(psutil, "pid_exists", wraps=FAKE_PID_exists):with pytest.raises(PidLockAlreadyHeld) as excinfo:_try_acquire_pid_lock(temp_pid_lock_file)assert (f"Unable to perform the operation as process with pid {FAKE_PID} already holds the lock"in str(excinfo.value))# The lock file should still contain the fake pidassert os.path.exists(temp_pid_lock_file)with open(temp_pid_lock_file) as fh:assert fh.read() == str(FAKE_PID)
1
14
1
95
0
129
154
129
temp_pid_lock_file
[]
Returns
{"Expr": 3, "Return": 1, "With": 4}
11
26
11
["open", "fh.write", "str", "patch.object", "pytest.raises", "_try_acquire_pid_lock", "str", "os.path.exists", "open", "fh.read", "str"]
0
[]
The function (test_check_pid_lock_when_process_running) defined within the public class called public.The function start at line 129 and ends at 154. It contains 14 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["open", "fh.write", "str", "patch.object", "pytest.raises", "_try_acquire_pid_lock", "str", "os.path.exists", "open", "fh.read", "str"].
aws-deadline_deadline-cloud
public
public
0
0
test_release_pid_lock_when_pid_does_not_match.FAKE_PID_exists
def FAKE_PID_exists(pid):return pid == FAKE_PID
1
2
1
9
0
169
170
169
null
[]
None
null
0
0
0
null
0
null
The function (test_release_pid_lock_when_pid_does_not_match.FAKE_PID_exists) defined within the public class called public.The function start at line 169 and ends at 170. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
aws-deadline_deadline-cloud
public
public
0
0
test_release_pid_lock_when_pid_does_not_match
def test_release_pid_lock_when_pid_does_not_match(temp_pid_lock_file):"""Tests releasing a PID lock when the PID doesn't match the current process.This happens when another process started concurrently and incorrectly claimedthe lock. Since the error is in a different process, it prints a warning andleaves the file."""# Write a PID that doesn't exist to the lock file (value is larger than PIDs are typically)with open(temp_pid_lock_file, "w") as fh:fh.write(str(FAKE_PID))# Patch psutil.pid_exists to return that the mock_pid existsdef FAKE_PID_exists(pid):return pid == FAKE_PIDwith patch.object(psutil, "pid_exists", wraps=FAKE_PID_exists), patch.object(_pid_file_lock, "logger") as logger_mock:_release_pid_lock(temp_pid_lock_file)# The function should have logged about leaving the lock fileassert logger_mock.warning.call_count == 1, f"{logger_mock.warning.call_args_list}"warning_message = logger_mock.warning.call_args.args[0]assert f"Another process with pid {FAKE_PID} claimed the pid lock" in warning_messageassert f"while {os.getpid()} was holding it. Skipping pid file deletion." in warning_message# The lock file should still contain the fake pidassert os.path.exists(temp_pid_lock_file)with open(temp_pid_lock_file) as fh:assert fh.read() == str(FAKE_PID)
1
15
1
117
1
157
186
157
temp_pid_lock_file
['warning_message']
Returns
{"Assign": 1, "Expr": 3, "Return": 1, "With": 3}
11
30
11
["open", "fh.write", "str", "patch.object", "patch.object", "_release_pid_lock", "os.getpid", "os.path.exists", "open", "fh.read", "str"]
0
[]
The function (test_release_pid_lock_when_pid_does_not_match) defined within the public class called public.The function start at line 157 and ends at 186. It contains 15 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters, and this function return a value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["open", "fh.write", "str", "patch.object", "patch.object", "_release_pid_lock", "os.getpid", "os.path.exists", "open", "fh.read", "str"].
aws-deadline_deadline-cloud
public
public
0
0
test_release_pid_lock_when_lock_not_held
def test_release_pid_lock_when_lock_not_held(temp_pid_lock_file):"""Tests releasing a PID lock when the lock isn't being held. Confirm a warning is generated."""# No pid lock file in this caseassert not os.path.exists(temp_pid_lock_file)with patch.object(_pid_file_lock, "logger") as logger_mock:_release_pid_lock(temp_pid_lock_file)# The function should have logged about leaving the lock fileassert logger_mock.warning.call_count == 1, f"{logger_mock.warning.call_args_list}"warning_message = logger_mock.warning.call_args.args[0]assert "Expected pid lock file does not exist at" in warning_message# The lock file should still not existassert not os.path.exists(temp_pid_lock_file)
1
8
1
69
1
189
205
189
temp_pid_lock_file
['warning_message']
None
{"Assign": 1, "Expr": 2, "With": 1}
4
17
4
["os.path.exists", "patch.object", "_release_pid_lock", "os.path.exists"]
0
[]
The function (test_release_pid_lock_when_lock_not_held) defined within the public class called public.The function start at line 189 and ends at 205. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["os.path.exists", "patch.object", "_release_pid_lock", "os.path.exists"].
aws-deadline_deadline-cloud
public
public
0
0
test_release_pid_lock_cleans_up_stale_temp_file
def test_release_pid_lock_cleans_up_stale_temp_file(temp_pid_lock_file):"""Tests releasing a PID lock when the temp file for claiming the lock hung around."""# Create the internal implementation detail temporary file for claiming the PID locktemp_file_for_claiming = _pid_lock_temp_file_path(temp_pid_lock_file)with open(temp_file_for_claiming, "w") as fh:fh.write(str(os.getpid()))# Also create the pid lock filewith open(temp_pid_lock_file, "w") as fh:fh.write(str(os.getpid()))with patch.object(_pid_file_lock, "logger") as logger_mock:_release_pid_lock(temp_pid_lock_file)# The function should have logged about leaving the lock fileassert logger_mock.warning.call_count == 1, f"{logger_mock.warning.call_args_list}"warning_message = logger_mock.warning.call_args.args[0]assert "Cleaned up stale pid lock temporary file" in warning_message# The lock file should not exist anymoreassert not os.path.exists(temp_pid_lock_file)# The temporary file for claiming the file should be gone nowassert not os.path.exists(temp_file_for_claiming)
1
13
1
121
2
208
233
208
temp_pid_lock_file
['temp_file_for_claiming', 'warning_message']
None
{"Assign": 2, "Expr": 4, "With": 3}
13
26
13
["_pid_lock_temp_file_path", "open", "fh.write", "str", "os.getpid", "open", "fh.write", "str", "os.getpid", "patch.object", "_release_pid_lock", "os.path.exists", "os.path.exists"]
0
[]
The function (test_release_pid_lock_cleans_up_stale_temp_file) defined within the public class called public.The function start at line 208 and ends at 233. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 13.0 functions, and It has 13.0 functions called inside which are ["_pid_lock_temp_file_path", "open", "fh.write", "str", "os.getpid", "open", "fh.write", "str", "os.getpid", "patch.object", "_release_pid_lock", "os.path.exists", "os.path.exists"].
aws-deadline_deadline-cloud
public
public
0
0
mock_api
def mock_api():"""Mock the API module."""with mock.patch("deadline.client.cli._groups.queue_group.api") as mock_api:# Mock the telemetry clientmock_api._telemetry.get_deadline_cloud_library_telemetry_client.return_value = (mock.MagicMock())yield mock_api
1
6
0
32
0
19
26
19
[]
None
{"Assign": 1, "Expr": 2, "With": 1}
2
8
2
["mock.patch", "mock.MagicMock"]
0
[]
The function (mock_api) defined within the public class called public.The function start at line 19 and ends at 26. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["mock.patch", "mock.MagicMock"].
aws-deadline_deadline-cloud
public
public
0
0
test_queue_export_credentials_user_mode
def test_queue_export_credentials_user_mode(mock_api, fresh_deadline_config):"""Test exporting credentials in USER mode."""# Setupexpiration = datetime.datetime(2025, 4, 8, 20, 0, 46)mock_api.assume_queue_role_for_user.return_value = {"credentials": {"accessKeyId": "ASIAEXAMPLE","secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","sessionToken": "AQoDYXdzEJr...<remainder of session token>","expiration": expiration,}}# Executerunner = CliRunner()result = runner.invoke(queue_export_credentials,["--farm-id", "f-abcdef12345", "--queue-id", "q-12345abcdef", "--mode", "USER"],)# Verifyassert result.exit_code == 0output = json.loads(result.output)assert output == {"Version": 1,"AccessKeyId": "ASIAEXAMPLE","SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","SessionToken": "AQoDYXdzEJr...<remainder of session token>","Expiration": expiration.isoformat(),}mock_api.assume_queue_role_for_user.assert_called_once_with(farmId="f-abcdef12345", queueId="q-12345abcdef", config=mock.ANY)# Verify telemetrytelemetry_client = mock_api._telemetry.get_deadline_cloud_library_telemetry_client.return_valuetelemetry_client.record_event.assert_called_once()event_name, event_details = telemetry_client.record_event.call_args[0]assert event_name == "com.amazon.rum.deadline.queue_export_credentials"assert event_details["mode"] == "USER"assert event_details["queue_id"] == "q-12345abcdef"assert event_details["is_success"] is Trueassert event_details["error_type"] is None
1
35
2
207
5
29
71
29
mock_api,fresh_deadline_config
['output', 'expiration', 'telemetry_client', 'runner', 'result']
None
{"Assign": 7, "Expr": 3}
7
43
7
["datetime.datetime", "CliRunner", "runner.invoke", "json.loads", "expiration.isoformat", "mock_api.assume_queue_role_for_user.assert_called_once_with", "telemetry_client.record_event.assert_called_once"]
0
[]
The function (test_queue_export_credentials_user_mode) defined within the public class called public.The function start at line 29 and ends at 71. It contains 35 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [29.0] and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["datetime.datetime", "CliRunner", "runner.invoke", "json.loads", "expiration.isoformat", "mock_api.assume_queue_role_for_user.assert_called_once_with", "telemetry_client.record_event.assert_called_once"].
aws-deadline_deadline-cloud
public
public
0
0
test_queue_export_credentials_read_mode
def test_queue_export_credentials_read_mode(mock_api, fresh_deadline_config):"""Test exporting credentials in READ mode."""# Setupexpiration = datetime.datetime(2025, 4, 8, 20, 0, 46)mock_api.assume_queue_role_for_read.return_value = {"credentials": {"accessKeyId": "ASIAEXAMPLE","secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","sessionToken": "AQoDYXdzEJr...<remainder of session token>","expiration": expiration,}}# Executerunner = CliRunner()result = runner.invoke(queue_export_credentials,["--farm-id", "f-abcdef12345", "--queue-id", "q-12345abcdef", "--mode", "READ"],)# Verifyassert result.exit_code == 0output = json.loads(result.output)assert output == {"Version": 1,"AccessKeyId": "ASIAEXAMPLE","SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","SessionToken": "AQoDYXdzEJr...<remainder of session token>","Expiration": expiration.isoformat(),}mock_api.assume_queue_role_for_read.assert_called_once_with(farmId="f-abcdef12345", queueId="q-12345abcdef", config=mock.ANY)
1
27
2
147
4
74
107
74
mock_api,fresh_deadline_config
['runner', 'result', 'expiration', 'output']
None
{"Assign": 5, "Expr": 2}
6
34
6
["datetime.datetime", "CliRunner", "runner.invoke", "json.loads", "expiration.isoformat", "mock_api.assume_queue_role_for_read.assert_called_once_with"]
0
[]
The function (test_queue_export_credentials_read_mode) defined within the public class called public.The function start at line 74 and ends at 107. It contains 27 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [74.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["datetime.datetime", "CliRunner", "runner.invoke", "json.loads", "expiration.isoformat", "mock_api.assume_queue_role_for_read.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_queue_export_credentials_default_queue_id
def test_queue_export_credentials_default_queue_id(mock_api, fresh_deadline_config):"""Test exporting credentials using default farm ID and queue ID from config."""# Setupexpiration = datetime.datetime(2025, 4, 8, 20, 0, 46)mock_api.assume_queue_role_for_user.return_value = {"credentials": {"accessKeyId": "ASIAEXAMPLE","secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","sessionToken": "AQoDYXdzEJr...<remainder of session token>","expiration": expiration,}}config_file.set_setting("defaults.farm_id", "f-default")config_file.set_setting("defaults.queue_id", "q-default")# Executerunner = CliRunner()result = runner.invoke(queue_export_credentials, [])# Verifyassert result.exit_code == 0, result.outputmock_api.assume_queue_role_for_user.assert_called_once_with(farmId="f-default", queueId="q-default", config=mock.ANY)
1
18
2
116
3
110
134
110
mock_api,fresh_deadline_config
['runner', 'result', 'expiration']
None
{"Assign": 4, "Expr": 4}
6
25
6
["datetime.datetime", "config_file.set_setting", "config_file.set_setting", "CliRunner", "runner.invoke", "mock_api.assume_queue_role_for_user.assert_called_once_with"]
0
[]
The function (test_queue_export_credentials_default_queue_id) defined within the public class called public.The function start at line 110 and ends at 134. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [110.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["datetime.datetime", "config_file.set_setting", "config_file.set_setting", "CliRunner", "runner.invoke", "mock_api.assume_queue_role_for_user.assert_called_once_with"].
aws-deadline_deadline-cloud
public
public
0
0
test_queue_export_credentials_client_error
def test_queue_export_credentials_client_error(mock_api, fresh_deadline_config):"""Test error handling when API call fails."""# Setupmock_api.assume_queue_role_for_user.side_effect = ClientError({"Error": {"Code": "AccessDeniedException", "Message": "Access denied"}},"AssumeQueueRoleForUser",)# Executerunner = CliRunner()result = runner.invoke(queue_export_credentials,["--farm-id", "f-abcdef12345", "--queue-id", "q-12345abcdef"],)# Verifyassert result.exit_code != 0assert "Insufficient permissions" in result.output# Verify telemetrytelemetry_client = mock_api._telemetry.get_deadline_cloud_library_telemetry_client.return_valuetelemetry_client.record_event.assert_called_once()event_name, event_details = telemetry_client.record_event.call_args[0]assert event_name == "com.amazon.rum.deadline.queue_export_credentials"assert event_details["is_success"] is Falseassert event_details["error_type"] == "ClientError"
1
18
2
115
3
137
163
137
mock_api,fresh_deadline_config
['runner', 'result', 'telemetry_client']
None
{"Assign": 5, "Expr": 2}
4
27
4
["ClientError", "CliRunner", "runner.invoke", "telemetry_client.record_event.assert_called_once"]
0
[]
The function (test_queue_export_credentials_client_error) defined within the public class called public.The function start at line 137 and ends at 163. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [137.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke", "telemetry_client.record_event.assert_called_once"].
aws-deadline_deadline-cloud
public
public
0
0
test_queue_export_credentials_auth_error
def test_queue_export_credentials_auth_error(mock_api, fresh_deadline_config):"""Test error handling when authentication fails."""# Setupmock_api.assume_queue_role_for_user.side_effect = ClientError({"Error": {"Code": "UnrecognizedClientException","Message": "The security token included in the request is invalid",}},"AssumeQueueRoleForUser",)# Executerunner = CliRunner()result = runner.invoke(queue_export_credentials,["--farm-id", "f-abcdef12345", "--queue-id", "q-12345abcdef"],)# Verifyassert result.exit_code != 0assert "Authentication failed" in result.output
1
17
2
70
2
166
189
166
mock_api,fresh_deadline_config
['runner', 'result']
None
{"Assign": 3, "Expr": 1}
3
24
3
["ClientError", "CliRunner", "runner.invoke"]
0
[]
The function (test_queue_export_credentials_auth_error) defined within the public class called public.The function start at line 166 and ends at 189. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [166.0] and does not return any value. It declares 3.0 functions, and It has 3.0 functions called inside which are ["ClientError", "CliRunner", "runner.invoke"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_settings_roundtrip
def test_config_settings_roundtrip(fresh_deadline_config, setting_name, default_value, alternate_value):"""Test that each setting we support has the right default and roundtrips changes"""assert config.get_setting(setting_name) == default_valueconfig.set_setting(setting_name, alternate_value)assert config.get_setting(setting_name) == alternate_value
1
6
4
38
0
32
38
32
fresh_deadline_config,setting_name,default_value,alternate_value
[]
None
{"Expr": 2}
4
7
4
["config.get_setting", "config.set_setting", "config.get_setting", "pytest.mark.parametrize"]
0
[]
The function (test_config_settings_roundtrip) defined within the public class called public.The function start at line 32 and ends at 38. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [32.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["config.get_setting", "config.set_setting", "config.get_setting", "pytest.mark.parametrize"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_settings_hierarchy
def test_config_settings_hierarchy(fresh_deadline_config):"""Test that settings are stored hierarchically,aws profile -> farm id -> queue id"""# First set some settings that apply to the defaults, changing the# hierarchy from queue inwards.config.set_setting("settings.storage_profile_id", "storage-profile-for-farm-default")config.set_setting("defaults.queue_id", "queue-for-farm-default")config.set_setting("defaults.farm_id", "farm-for-profile-default")config.set_setting("defaults.aws_profile_name", "NonDefaultProfile")# Confirm that all child settings we changed are default, because they were# for a different profile.assert config.get_setting("defaults.farm_id") == ""assert config.get_setting("defaults.queue_id") == ""assert config.get_setting("settings.storage_profile_id") == ""# Switch back to the default profile, and check the next layer of the onionconfig.clear_setting("defaults.aws_profile_name")assert config.get_setting("defaults.farm_id") == "farm-for-profile-default"# The queue id is still defaultassert config.get_setting("defaults.queue_id") == ""# The storage profile id is still defaultassert config.get_setting("settings.storage_profile_id") == ""# Switch back to the default farmconfig.clear_setting("defaults.farm_id")assert config.get_setting("defaults.queue_id") == "queue-for-farm-default"# Storage profile needs "profile - farm_id" so it should be back to the originalassert config.get_setting("settings.storage_profile_id") == "storage-profile-for-farm-default"# Switch to default farm and default queueconfig.clear_setting("defaults.queue_id")assert config.get_setting("settings.storage_profile_id") == "storage-profile-for-farm-default"
1
17
1
137
0
41
75
41
fresh_deadline_config
[]
None
{"Expr": 8}
16
35
16
["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "config.get_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting"]
0
[]
The function (test_config_settings_hierarchy) defined within the public class called public.The function start at line 41 and ends at 75. It contains 17 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 16.0 functions, and It has 16.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "config.get_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting", "config.get_setting", "config.clear_setting", "config.get_setting"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_get_setting_nonexistant
def test_config_get_setting_nonexistant(fresh_deadline_config):"""Test the error from get_setting when a setting doesn't exist."""# Setting name without the '.'with pytest.raises(DeadlineOperationError) as excinfo:config.get_setting("setting_name_bad_format")assert "is not valid" in str(excinfo.value)assert "setting_name_bad_format" in str(excinfo.value)# Section name is wrongwith pytest.raises(DeadlineOperationError) as excinfo:config.get_setting("setitngs.aws_profile_name")assert "has no setting" in str(excinfo.value)assert "setitngs" in str(excinfo.value)# Section is good, but no settingwith pytest.raises(DeadlineOperationError) as excinfo:config.get_setting("settings.aws_porfile_name")assert "has no setting" in str(excinfo.value)assert "aws_porfile_name" in str(excinfo.value)
1
13
1
108
0
78
96
78
fresh_deadline_config
[]
None
{"Expr": 4, "With": 3}
12
19
12
["pytest.raises", "config.get_setting", "str", "str", "pytest.raises", "config.get_setting", "str", "str", "pytest.raises", "config.get_setting", "str", "str"]
0
[]
The function (test_config_get_setting_nonexistant) defined within the public class called public.The function start at line 78 and ends at 96. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 12.0 functions, and It has 12.0 functions called inside which are ["pytest.raises", "config.get_setting", "str", "str", "pytest.raises", "config.get_setting", "str", "str", "pytest.raises", "config.get_setting", "str", "str"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_set_setting_nonexistant
def test_config_set_setting_nonexistant(fresh_deadline_config):"""Test the error from set_setting when a setting doesn't exist."""# Setting name without the '.'with pytest.raises(DeadlineOperationError) as excinfo:config.set_setting("setting_name_bad_format", "value")assert "is not valid" in str(excinfo.value)assert "setting_name_bad_format" in str(excinfo.value)# Section name is wrongwith pytest.raises(DeadlineOperationError) as excinfo:config.set_setting("setitngs.aws_profile_name", "value")assert "has no setting" in str(excinfo.value)assert "setitngs" in str(excinfo.value)# Section is good, but no settingwith pytest.raises(DeadlineOperationError) as excinfo:config.set_setting("settings.aws_porfile_name", "value")assert "has no setting" in str(excinfo.value)assert "aws_porfile_name" in str(excinfo.value)
1
13
1
114
0
99
117
99
fresh_deadline_config
[]
None
{"Expr": 4, "With": 3}
12
19
12
["pytest.raises", "config.set_setting", "str", "str", "pytest.raises", "config.set_setting", "str", "str", "pytest.raises", "config.set_setting", "str", "str"]
0
[]
The function (test_config_set_setting_nonexistant) defined within the public class called public.The function start at line 99 and ends at 117. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 12.0 functions, and It has 12.0 functions called inside which are ["pytest.raises", "config.set_setting", "str", "str", "pytest.raises", "config.set_setting", "str", "str", "pytest.raises", "config.set_setting", "str", "str"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_clear_setting_nonexistant
def test_config_clear_setting_nonexistant(fresh_deadline_config):"""Test the error from clear_setting when a setting doesn't exist."""# Setting name without the '.'with pytest.raises(DeadlineOperationError) as excinfo:config.clear_setting("setting_name_bad_format")assert "is not valid" in str(excinfo.value)assert "setting_name_bad_format" in str(excinfo.value)# Section name is wrongwith pytest.raises(DeadlineOperationError) as excinfo:config.clear_setting("setitngs.aws_profile_name")assert "has no setting" in str(excinfo.value)assert "setitngs" in str(excinfo.value)# Section is good, but no settingwith pytest.raises(DeadlineOperationError) as excinfo:config.clear_setting("settings.aws_porfile_name")assert "has no setting" in str(excinfo.value)assert "aws_porfile_name" in str(excinfo.value)
1
13
1
108
0
120
138
120
fresh_deadline_config
[]
None
{"Expr": 4, "With": 3}
12
19
12
["pytest.raises", "config.clear_setting", "str", "str", "pytest.raises", "config.clear_setting", "str", "str", "pytest.raises", "config.clear_setting", "str", "str"]
0
[]
The function (test_config_clear_setting_nonexistant) defined within the public class called public.The function start at line 120 and ends at 138. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 12.0 functions, and It has 12.0 functions called inside which are ["pytest.raises", "config.clear_setting", "str", "str", "pytest.raises", "config.clear_setting", "str", "str", "pytest.raises", "config.clear_setting", "str", "str"].
aws-deadline_deadline-cloud
public
public
0
0
test_config_file_env_var
def test_config_file_env_var(fresh_deadline_config):"""Test that setting the env var DEADLINE_CONFIG_FILE_PATH overrides the config path"""assert config_file.get_config_file_path() == Path(fresh_deadline_config).expanduser()alternate_deadline_config_file = fresh_deadline_config + "_alternative_file"# Set our config file to a known starting pointconfig.set_setting("defaults.aws_profile_name", "EnvVarOverrideProfile")assert config.get_setting("defaults.aws_profile_name") == "EnvVarOverrideProfile"with open(fresh_deadline_config, "r", encoding="utf-8") as f:assert "aws_profile_name = EnvVarOverrideProfile" in f.read()try:# Set the override environment variableos.environ["DEADLINE_CONFIG_FILE_PATH"] = alternate_deadline_config_fileassert (config_file.get_config_file_path() == Path(alternate_deadline_config_file).expanduser())# Confirm that we see the default settings againassert config.get_setting("defaults.aws_profile_name") == "(default)"# Change the settings in this new fileconfig.set_setting("defaults.aws_profile_name", "AlternateProfileName")assert config.get_setting("defaults.aws_profile_name") == "AlternateProfileName"with open(alternate_deadline_config_file, "r", encoding="utf-8") as f:assert "aws_profile_name = AlternateProfileName" in f.read()# Remove the overridedel os.environ["DEADLINE_CONFIG_FILE_PATH"]assert config_file.get_config_file_path() == Path(fresh_deadline_config).expanduser()# We should see the known starting point againassert config.get_setting("defaults.aws_profile_name") == "EnvVarOverrideProfile"# Set the override environment variable againos.environ["DEADLINE_CONFIG_FILE_PATH"] = alternate_deadline_config_fileassert (config_file.get_config_file_path() == Path(alternate_deadline_config_file).expanduser())assert config.get_setting("defaults.aws_profile_name") == "AlternateProfileName"finally:os.unlink(alternate_deadline_config_file)if "DEADLINE_CONFIG_FILE_PATH" in os.environ:del os.environ["DEADLINE_CONFIG_FILE_PATH"]
3
29
1
227
1
142
187
142
fresh_deadline_config
['alternate_deadline_config_file']
None
{"Assign": 3, "Expr": 4, "If": 1, "Try": 1, "With": 2}
26
46
26
["config_file.get_config_file_path", "expanduser", "Path", "config.set_setting", "config.get_setting", "open", "f.read", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "config.set_setting", "config.get_setting", "open", "f.read", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "os.unlink", "patch.object", "MagicMock"]
0
[]
The function (test_config_file_env_var) defined within the public class called public.The function start at line 142 and ends at 187. It contains 29 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value. It declares 26.0 functions, and It has 26.0 functions called inside which are ["config_file.get_config_file_path", "expanduser", "Path", "config.set_setting", "config.get_setting", "open", "f.read", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "config.set_setting", "config.get_setting", "open", "f.read", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "config_file.get_config_file_path", "expanduser", "Path", "config.get_setting", "os.unlink", "patch.object", "MagicMock"].
aws-deadline_deadline-cloud
public
public
0
0
test_get_best_profile_for_farm
def test_get_best_profile_for_farm(fresh_deadline_config):"""Test that it returns the exact farm + queue id match"""PROFILE_SETTINGS = [("Profile1", "farm-1", "queue-1"),("Profile2", "farm-2", "queue-2"),("Profile3", "farm-1", "queue-3"),("Profile4", "farm-3", "queue-4"),("Profile5", "farm-3", "queue-5"),("Profile6", "", ""),]for profile_name, farm_id, queue_id in PROFILE_SETTINGS:config.set_setting("defaults.aws_profile_name", profile_name)config.set_setting("defaults.farm_id", farm_id)config.set_setting("defaults.queue_id", queue_id)with patch.object(boto3, "Session") as boto3_session:MOCK_PROFILE_VALUE = {"sso_start_url": "https://d-012345abcd.awsapps.com/start","sso_region": "us-west-2","sso_account_id": "123456789012","sso_role_name": "AwsProfileForDeadline","region": "us-west-2",}boto3_session()._session.full_config = {"profiles": {profile_settings[0]: MOCK_PROFILE_VALUE for profile_settings in PROFILE_SETTINGS},}# In each case, when the default profile doesn't match the farm,# an exact match of farm/queue id should return the corresponding profilefor profile_name, farm_id, queue_id in PROFILE_SETTINGS:if farm_id:assert config.get_best_profile_for_farm(farm_id, queue_id) == profile_name# Getting the best profile should not have modified the defaultassert config.get_setting("defaults.aws_profile_name") == "Profile6"# Matching just the farm id should return the first matching profileassert config.get_best_profile_for_farm("farm-1") == "Profile1"assert config.get_best_profile_for_farm("farm-2") == "Profile2"assert config.get_best_profile_for_farm("farm-3") == "Profile4"# Matching the farm id with a missing queue id should return the first matching profileassert config.get_best_profile_for_farm("farm-1", "queue-missing") == "Profile1"assert config.get_best_profile_for_farm("farm-2", "queue-missing") == "Profile2"assert config.get_best_profile_for_farm("farm-3", "queue-missing") == "Profile4"# If the farm id doesn't match, should return the default (which is Profile6)assert config.get_best_profile_for_farm("farm-missing") == "Profile6"assert config.get_best_profile_for_farm("farm-missing", "queue-missing") == "Profile6"# If the farm id does match, should return the default even if it isn't the first matchconfig.set_setting("defaults.aws_profile_name", "Profile5")assert config.get_best_profile_for_farm("farm-1") == "Profile1"assert config.get_best_profile_for_farm("farm-2") == "Profile2"# For farm-3, the first match is Profile4, but the default is Profile5assert config.get_best_profile_for_farm("farm-3") == "Profile5"
5
42
1
299
2
190
248
190
fresh_deadline_config
['PROFILE_SETTINGS', 'MOCK_PROFILE_VALUE']
None
{"Assign": 3, "Expr": 5, "For": 2, "If": 1, "With": 1}
19
59
19
["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "boto3_session", "config.get_best_profile_for_farm", "config.get_setting", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.set_setting", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm"]
0
[]
The function (test_get_best_profile_for_farm) defined within the public class called public.The function start at line 190 and ends at 248. It contains 42 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value. It declares 19.0 functions, and It has 19.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch.object", "boto3_session", "config.get_best_profile_for_farm", "config.get_setting", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.set_setting", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm", "config.get_best_profile_for_farm"].
aws-deadline_deadline-cloud
public
public
0
0
test_str2bool
def test_str2bool():assert config_file.str2bool("on") is Trueassert config_file.str2bool("true") is Trueassert config_file.str2bool("tRuE") is Trueassert config_file.str2bool("1") is Trueassert config_file.str2bool("off") is Falseassert config_file.str2bool("false") is Falseassert config_file.str2bool("FaLsE") is Falseassert config_file.str2bool("0") is Falsewith pytest.raises(ValueError):config_file.str2bool("not_boolean")with pytest.raises(ValueError):config_file.str2bool("")
1
13
0
104
0
251
263
251
[]
None
{"Expr": 2, "With": 2}
12
13
12
["config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "pytest.raises", "config_file.str2bool", "pytest.raises", "config_file.str2bool"]
0
[]
The function (test_str2bool) defined within the public class called public.The function start at line 251 and ends at 263. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 12.0 functions, and It has 12.0 functions called inside which are ["config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "config_file.str2bool", "pytest.raises", "config_file.str2bool", "pytest.raises", "config_file.str2bool"].
aws-deadline_deadline-cloud
public
public
0
0
test_default_log_level
def test_default_log_level(fresh_deadline_config):# To avoid excessive logging, the log level should not be DEBUG by default.assert config.get_setting("settings.log_level") != "DEBUG"# Verify the default log level exists and is less verbose than DEBUGassert config.get_setting("settings.log_level") == "WARNING"
1
3
1
23
0
266
270
266
fresh_deadline_config
[]
None
{}
2
5
2
["config.get_setting", "config.get_setting"]
0
[]
The function (test_default_log_level) defined within the public class called public.The function start at line 266 and ends at 270. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 2.0 functions, and It has 2.0 functions called inside which are ["config.get_setting", "config.get_setting"].
aws-deadline_deadline-cloud
public
public
0
0
test_reset_directory_permissions_windows
def test_reset_directory_permissions_windows() -> None:"""Asserts the _reset_directory_permissions_windows configures the providedfolder with access only to the active user, the domain admin, and SYSTEM."""# GIVENimport ntsecurityconimport win32securitypath = Path(tempfile.gettempdir())system_sid = win32security.ConvertStringSidToSid("S-1-5-18")admin_sid = win32security.ConvertStringSidToSid("S-1-5-32-544")user_sid, _, _ = win32security.LookupAccountName(None, getpass.getuser())sids = [system_sid, admin_sid, user_sid]# WHENconfig_file._reset_directory_permissions_windows(path)# THENsd = win32security.GetFileSecurity(str(path.resolve()), win32security.DACL_SECURITY_INFORMATION)dacl = sd.GetSecurityDescriptorDacl()assert dacl.GetAceCount() == 3assert dacl.GetAclRevision() == win32security.ACL_REVISIONfor i in range(3):(acetype, aceflags), access, sid = dacl.GetAce(i)assert acetype == win32security.ACCESS_ALLOWED_ACE_TYPEassert aceflags == ntsecuritycon.OBJECT_INHERIT_ACE | ntsecuritycon.CONTAINER_INHERIT_ACEassert access == ntsecuritycon.FILE_ALL_ACCESStry:sids.remove(sid)except ValueError:assert False, f"Unexpected SID: {win32security.ConvertSidToStringSid(sid)}"
3
22
0
176
6
277
308
277
['admin_sid', 'sids', 'dacl', 'sd', 'path', 'system_sid']
None
{"Assign": 8, "Expr": 3, "For": 1, "Try": 1}
19
32
19
["Path", "tempfile.gettempdir", "win32security.ConvertStringSidToSid", "win32security.ConvertStringSidToSid", "win32security.LookupAccountName", "getpass.getuser", "config_file._reset_directory_permissions_windows", "win32security.GetFileSecurity", "str", "path.resolve", "sd.GetSecurityDescriptorDacl", "dacl.GetAceCount", "dacl.GetAclRevision", "range", "dacl.GetAce", "sids.remove", "win32security.ConvertSidToStringSid", "pytest.mark.skipif", "platform.system"]
0
[]
The function (test_reset_directory_permissions_windows) defined within the public class called public.The function start at line 277 and ends at 308. It contains 22 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value. It declares 19.0 functions, and It has 19.0 functions called inside which are ["Path", "tempfile.gettempdir", "win32security.ConvertStringSidToSid", "win32security.ConvertStringSidToSid", "win32security.LookupAccountName", "getpass.getuser", "config_file._reset_directory_permissions_windows", "win32security.GetFileSecurity", "str", "path.resolve", "sd.GetSecurityDescriptorDacl", "dacl.GetAceCount", "dacl.GetAclRevision", "range", "dacl.GetAce", "sids.remove", "win32security.ConvertSidToStringSid", "pytest.mark.skipif", "platform.system"].
aws-deadline_deadline-cloud
public
public
0
0
test_write_config_directory_permission_windows
def test_write_config_directory_permission_windows(mock_get_config_file_path,):"""Tests that the config directory permissions are not modified when writing to the config file"""# GIVENpath = Path(tempfile.gettempdir())config_path = path / "config"mock_get_config_file_path.return_value = config_path# ----------------------------------------------------------------------------------------------# Sets up a directory with an added full access entry for domain guests. Since this is not a# typically expected entry, it can be used to validate existing permissions were not overwrittenimport win32securityimport ntsecurityconsd = win32security.GetFileSecurity(str(path.resolve()), win32security.DACL_SECURITY_INFORMATION)guest_sid = win32security.ConvertStringSidToSid("S-1-5-32-546")# Domain Guestsdacl = sd.GetSecurityDescriptorDacl()dacl.AddAccessAllowedAceEx(win32security.ACL_REVISION,ntsecuritycon.OBJECT_INHERIT_ACE | ntsecuritycon.CONTAINER_INHERIT_ACE,ntsecuritycon.FILE_ALL_ACCESS,guest_sid,)sd.SetSecurityDescriptorDacl(1, dacl, 0)win32security.SetFileSecurity(str(path.resolve()), win32security.DACL_SECURITY_INFORMATION, sd)# ----------------------------------------------------------------------------------------------# WHENconfig_file.write_config(MagicMock())# THENnew_dacl = win32security.GetFileSecurity(str(path.resolve()), win32security.DACL_SECURITY_INFORMATION).GetSecurityDescriptorDacl()new_dacl_aces = [new_dacl.GetAce(i) for i in range(new_dacl.GetAceCount())]dacl_aces = [dacl.GetAce(i) for i in range(dacl.GetAceCount())]# Assert the access control entries are identicalassert new_dacl_aces == dacl_aces
3
26
1
194
8
316
358
316
mock_get_config_file_path
['new_dacl_aces', 'dacl', 'config_path', 'sd', 'new_dacl', 'guest_sid', 'path', 'dacl_aces']
None
{"Assign": 9, "Expr": 5}
27
43
27
["Path", "tempfile.gettempdir", "win32security.GetFileSecurity", "str", "path.resolve", "win32security.ConvertStringSidToSid", "sd.GetSecurityDescriptorDacl", "dacl.AddAccessAllowedAceEx", "sd.SetSecurityDescriptorDacl", "win32security.SetFileSecurity", "str", "path.resolve", "config_file.write_config", "MagicMock", "GetSecurityDescriptorDacl", "win32security.GetFileSecurity", "str", "path.resolve", "new_dacl.GetAce", "range", "new_dacl.GetAceCount", "dacl.GetAce", "range", "dacl.GetAceCount", "pytest.mark.skipif", "platform.system", "patch.object"]
0
[]
The function (test_write_config_directory_permission_windows) defined within the public class called public.The function start at line 316 and ends at 358. It contains 26 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value. It declares 27.0 functions, and It has 27.0 functions called inside which are ["Path", "tempfile.gettempdir", "win32security.GetFileSecurity", "str", "path.resolve", "win32security.ConvertStringSidToSid", "sd.GetSecurityDescriptorDacl", "dacl.AddAccessAllowedAceEx", "sd.SetSecurityDescriptorDacl", "win32security.SetFileSecurity", "str", "path.resolve", "config_file.write_config", "MagicMock", "GetSecurityDescriptorDacl", "win32security.GetFileSecurity", "str", "path.resolve", "new_dacl.GetAce", "range", "new_dacl.GetAceCount", "dacl.GetAce", "range", "dacl.GetAceCount", "pytest.mark.skipif", "platform.system", "patch.object"].
aws-deadline_deadline-cloud
public
public
0
0
test_posix_config_file_permissions
def test_posix_config_file_permissions(fresh_deadline_config) -> None:config_file_path = config_file.get_config_file_path()config_file_path.chmod(0o777)config_file.set_setting("defaults.aws_profile_name", "goodguyprofile")assert config_file_path.stat().st_mode & 0o777 == 0o600
1
5
1
40
1
365
371
365
fresh_deadline_config
['config_file_path']
None
{"Assign": 1, "Expr": 2}
6
7
6
["config_file.get_config_file_path", "config_file_path.chmod", "config_file.set_setting", "config_file_path.stat", "pytest.mark.skipif", "platform.system"]
0
[]
The function (test_posix_config_file_permissions) defined within the public class called public.The function start at line 365 and ends at 371. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["config_file.get_config_file_path", "config_file_path.chmod", "config_file.set_setting", "config_file_path.stat", "pytest.mark.skipif", "platform.system"].
aws-deadline_deadline-cloud
public
public
0
0
_get_inclusive_range
def _get_inclusive_range(start, end, step):if end is None and step is None:return [start]elif (end is Noneor start is Noneor start < endand step is not Noneand step < 0or start > endand step is not Noneand step > 0):return Noneif step is None:step = 1 if end > start else -1return list(range(start, end + (1 if step > 0 else -1), step))
14
17
3
99
1
44
60
44
start,end,step
['step']
Returns
{"Assign": 1, "If": 3, "Return": 3}
2
17
2
["list", "range"]
1
["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.job_bundle.test_adaptors_py.test_parse_frame_range"]
The function (_get_inclusive_range) defined within the public class called public.The function start at line 44 and ends at 60. It contains 17 lines of code and it has a cyclomatic complexity of 14. It takes 3 parameters, represented as [44.0], and this function return a value. It declares 2.0 functions, It has 2.0 functions called inside which are ["list", "range"], It has 1.0 function calling this function which is ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.job_bundle.test_adaptors_py.test_parse_frame_range"].
aws-deadline_deadline-cloud
public
public
0
0
test_parse_frame_range
def test_parse_frame_range(frame_string: str, result: list[int]):if result is None:with pytest.raises(ValueError):parse_frame_range(frame_string)else:assert parse_frame_range(frame_string) == result
2
6
2
40
0
75
80
75
frame_string,result
[]
None
{"Expr": 1, "If": 1, "With": 1}
7
6
7
["pytest.raises", "parse_frame_range", "parse_frame_range", "pytest.mark.parametrize", "str", "str", "_get_inclusive_range"]
0
[]
The function (test_parse_frame_range) defined within the public class called public.The function start at line 75 and ends at 80. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [75.0] and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["pytest.raises", "parse_frame_range", "parse_frame_range", "pytest.mark.parametrize", "str", "str", "_get_inclusive_range"].
aws-deadline_deadline-cloud
public
public
0
0
test_read_job_bundle_parameters
def test_read_job_bundle_parameters(template_data,parameter_values,expected_result,fresh_deadline_config,temp_job_bundle_dir,):"""Tests that the read_job_bundle_parameters function loads the"""# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, "template.yaml"),"w",encoding="utf8",) as f:f.write(template_data)# Write the parameter values to the job bundlewith open(os.path.join(temp_job_bundle_dir, "parameter_values.yaml"),"w",encoding="utf8",) as f:f.write(parameter_values)# Now load the parameters from this job bundleresult = read_job_bundle_parameters(temp_job_bundle_dir)# In the test data, we set the directory picker 1 parameter value, but let# the directory picker 2 parameter value fall back to the default, which causes# it to expand into a path internal to the job bundle.directory_picker_2_value = json.dumps(os.path.normpath(os.path.join(temp_job_bundle_dir, "./internal/directory")))assert result == yaml.safe_load(expected_result.format(DIRECTORY_PICKER_2_VALUE=directory_picker_2_value))
1
26
5
121
2
140
177
140
template_data,parameter_values,expected_result,fresh_deadline_config,temp_job_bundle_dir
['result', 'directory_picker_2_value']
None
{"Assign": 2, "Expr": 3, "With": 2}
14
38
14
["open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "read_job_bundle_parameters", "json.dumps", "os.path.normpath", "os.path.join", "yaml.safe_load", "expected_result.format", "pytest.mark.parametrize", "pytest.param"]
0
[]
The function (test_read_job_bundle_parameters) defined within the public class called public.The function start at line 140 and ends at 177. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [140.0] and does not return any value. It declares 14.0 functions, and It has 14.0 functions called inside which are ["open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "read_job_bundle_parameters", "json.dumps", "os.path.normpath", "os.path.join", "yaml.safe_load", "expected_result.format", "pytest.mark.parametrize", "pytest.param"].