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_record_upload_summary | def test_record_upload_summary(fresh_deadline_config, mock_telemetry_client):"""Tests that recording an upload summary sends the expected TelemetryEvent to the thread queue"""# GIVENqueue_mock = MagicMock()test_summary = SummaryStatistics(total_bytes=123, total_files=12, total_time=12345)expected_summary = asdict(test_summary)expected_summary["usage_mode"] = "GUI"expected_summary["accountId"] = "111122223333"expected_event = TelemetryEvent(event_type="com.amazon.rum.deadline.job_attachments.upload_summary",event_details=expected_summary,)mock_telemetry_client.event_queue = queue_mock# WHENwith patch.object(mock_telemetry_client, "get_account_id", return_value="111122223333"), patch.object(api._telemetry, "get_boto3_session"):mock_telemetry_client.record_upload_summary(test_summary, from_gui=True)# THENqueue_mock.put_nowait.assert_called_once_with(expected_event) | 1 | 16 | 2 | 108 | 4 | 233 | 254 | 233 | fresh_deadline_config,mock_telemetry_client | ['expected_event', 'queue_mock', 'expected_summary', 'test_summary'] | None | {"Assign": 7, "Expr": 3, "With": 1} | 8 | 22 | 8 | ["MagicMock", "SummaryStatistics", "asdict", "TelemetryEvent", "patch.object", "patch.object", "mock_telemetry_client.record_upload_summary", "queue_mock.put_nowait.assert_called_once_with"] | 0 | [] | The function (test_record_upload_summary) defined within the public class called public.The function start at line 233 and ends at 254. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [233.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["MagicMock", "SummaryStatistics", "asdict", "TelemetryEvent", "patch.object", "patch.object", "mock_telemetry_client.record_upload_summary", "queue_mock.put_nowait.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_record_error | def test_record_error(fresh_deadline_config, mock_telemetry_client):"""Test that recording an error sends the expected TelemetryEvent to the thread queue"""# GIVENqueue_mock = MagicMock()test_error_details = {"some_field": "some_value"}test_exc = Exception("some exception")expected_event_details = {"some_field": "some_value","exception_type": str(type(test_exc)),"usage_mode": "CLI","accountId": "111122223333",}expected_event = TelemetryEvent(event_type="com.amazon.rum.deadline.error", event_details=expected_event_details)mock_telemetry_client.event_queue = queue_mockwith patch.object(mock_telemetry_client, "get_account_id", return_value="111122223333"), patch.object(api._telemetry, "get_boto3_session"):# WHENmock_telemetry_client.record_error(test_error_details, str(type(test_exc)))# THENqueue_mock.put_nowait.assert_called_once_with(expected_event) | 1 | 19 | 2 | 116 | 5 | 257 | 281 | 257 | fresh_deadline_config,mock_telemetry_client | ['expected_event_details', 'expected_event', 'test_exc', 'queue_mock', 'test_error_details'] | None | {"Assign": 6, "Expr": 3, "With": 1} | 11 | 25 | 11 | ["MagicMock", "Exception", "str", "type", "TelemetryEvent", "patch.object", "patch.object", "mock_telemetry_client.record_error", "str", "type", "queue_mock.put_nowait.assert_called_once_with"] | 0 | [] | The function (test_record_error) defined within the public class called public.The function start at line 257 and ends at 281. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [257.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["MagicMock", "Exception", "str", "type", "TelemetryEvent", "patch.object", "patch.object", "mock_telemetry_client.record_error", "str", "type", "queue_mock.put_nowait.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_prefixed_endpoint | def test_get_prefixed_endpoint(fresh_deadline_config,mock_telemetry_client: TelemetryClient,endpoint: str,prefix: str,expected_result: str,):"""Test that the _get_prefixed_endpoint function returns the expected prefixed endpoint"""assert mock_telemetry_client._get_prefixed_endpoint(endpoint, prefix) == expected_result | 1 | 8 | 5 | 34 | 0 | 307 | 315 | 307 | fresh_deadline_config,mock_telemetry_client,endpoint,prefix,expected_result | [] | None | {"Expr": 1} | 5 | 9 | 5 | ["mock_telemetry_client._get_prefixed_endpoint", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param"] | 0 | [] | The function (test_get_prefixed_endpoint) defined within the public class called public.The function start at line 307 and ends at 315. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [307.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["mock_telemetry_client._get_prefixed_endpoint", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_record_decorator_success.successful | def successful():return | 1 | 2 | 0 | 5 | 0 | 341 | 342 | 341 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_record_decorator_success.successful) defined within the public class called public.The function start at line 341 and ends at 342. 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_record_decorator_success | def test_record_decorator_success(fresh_deadline_config):"""Tests that recording a decorator successful metric"""with patch.object(api._telemetry, "get_deadline_endpoint_url", side_effect=["https://fake-endpoint-url"]):# GIVENqueue_mock = MagicMock()expected_summary: Dict[str, Any] = dict()expected_summary["is_success"] = Trueexpected_summary["usage_mode"] = "CLI"expected_summary["accountId"] = "111122223333"expected_event = TelemetryEvent(event_type="com.amazon.rum.deadline.successful",event_details=expected_summary,)telemetry_client = get_deadline_cloud_library_telemetry_client()telemetry_client.event_queue = queue_mockwith patch.object(api.TelemetryClient, "get_account_id", return_value="111122223333"), patch.object(api._telemetry, "get_boto3_session"):@record_success_fail_telemetry_event()def successful():return# WHENsuccessful()# type:ignore# THENqueue_mock.put_nowait.assert_called_once_with(expected_event) | 1 | 22 | 1 | 126 | 3 | 318 | 348 | 318 | fresh_deadline_config | ['expected_event', 'telemetry_client', 'queue_mock'] | None | {"AnnAssign": 1, "Assign": 7, "Expr": 3, "Return": 1, "With": 2} | 10 | 31 | 10 | ["patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "record_success_fail_telemetry_event", "successful", "queue_mock.put_nowait.assert_called_once_with"] | 0 | [] | The function (test_record_decorator_success) defined within the public class called public.The function start at line 318 and ends at 348. 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 10.0 functions, and It has 10.0 functions called inside which are ["patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "record_success_fail_telemetry_event", "successful", "queue_mock.put_nowait.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_record_decorator_fails.fails | def fails():raise RuntimeError("foobar") | 1 | 2 | 0 | 9 | 0 | 375 | 376 | 375 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_record_decorator_fails.fails) defined within the public class called public.The function start at line 375 and ends at 376. 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_record_decorator_fails | def test_record_decorator_fails(fresh_deadline_config):"""Tests that recording a decorator failed metric"""with patch.object(api._telemetry, "get_deadline_endpoint_url", side_effect=["https://fake-endpoint-url"]):# GIVENqueue_mock = MagicMock()expected_summary: Dict[str, Any] = dict()expected_summary["is_success"] = Falseexpected_summary["exception_type"] = "RuntimeError"expected_summary["usage_mode"] = "CLI"expected_summary["accountId"] = "111122223333"expected_event = TelemetryEvent(event_type="com.amazon.rum.deadline.fails",event_details=expected_summary,)telemetry_client = get_deadline_cloud_library_telemetry_client()telemetry_client.event_queue = queue_mockwith patch.object(api.TelemetryClient, "get_account_id", return_value="111122223333"), patch.object(api._telemetry, "get_boto3_session"):@record_success_fail_telemetry_event()def fails():raise RuntimeError("foobar")# WHENwith pytest.raises(RuntimeError):fails()# type:ignore# THENqueue_mock.put_nowait.assert_called_once_with(expected_event) | 1 | 24 | 1 | 140 | 3 | 351 | 383 | 351 | fresh_deadline_config | ['expected_event', 'telemetry_client', 'queue_mock'] | None | {"AnnAssign": 1, "Assign": 8, "Expr": 3, "With": 3} | 12 | 33 | 12 | ["patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "RuntimeError", "record_success_fail_telemetry_event", "pytest.raises", "fails", "queue_mock.put_nowait.assert_called_once_with"] | 0 | [] | The function (test_record_decorator_fails) defined within the public class called public.The function start at line 351 and ends at 383. It contains 24 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 ["patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "RuntimeError", "record_success_fail_telemetry_event", "pytest.raises", "fails", "queue_mock.put_nowait.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_latency_decorator.test_call | def test_call():return | 1 | 2 | 0 | 5 | 0 | 410 | 411 | 410 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_latency_decorator.test_call) defined within the public class called public.The function start at line 410 and ends at 411. 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_latency_decorator | def test_latency_decorator(fresh_deadline_config):"""Tests that the latency recording decorator works"""with patch.object(api._telemetry, "get_deadline_endpoint_url", side_effect=["https://fake-endpoint-url"]), patch.object(time, "perf_counter_ns", return_value=0):# GIVENqueue_mock = MagicMock()expected_summary: Dict[str, Any] = dict()expected_summary["latency"] = 0expected_summary["function_call"] = "test_call"expected_summary["usage_mode"] = "CLI"expected_summary["accountId"] = "111122223333"expected_event = TelemetryEvent(event_type="com.amazon.rum.deadline.latency",event_details=expected_summary,)telemetry_client = get_deadline_cloud_library_telemetry_client()telemetry_client.event_queue = queue_mockwith patch.object(api.TelemetryClient, "get_account_id", return_value="111122223333"), patch.object(api._telemetry, "get_boto3_session"):@record_function_latency_telemetry_event()def test_call():return# WHENtest_call()# type:ignore# THENqueue_mock.put_nowait.assert_called_once_with(expected_event) | 1 | 23 | 1 | 145 | 3 | 386 | 417 | 386 | fresh_deadline_config | ['expected_event', 'telemetry_client', 'queue_mock'] | None | {"AnnAssign": 1, "Assign": 8, "Expr": 3, "Return": 1, "With": 2} | 11 | 32 | 11 | ["patch.object", "patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "record_function_latency_telemetry_event", "test_call", "queue_mock.put_nowait.assert_called_once_with"] | 0 | [] | The function (test_latency_decorator) defined within the public class called public.The function start at line 386 and ends at 417. It contains 23 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 11.0 functions, and It has 11.0 functions called inside which are ["patch.object", "patch.object", "MagicMock", "dict", "TelemetryEvent", "get_deadline_cloud_library_telemetry_client", "patch.object", "patch.object", "record_function_latency_telemetry_event", "test_call", "queue_mock.put_nowait.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | get_minimal_json_job_template | def get_minimal_json_job_template(job_name):return json.dumps({"specificationVersion": "jobtemplate-2023-09","name": job_name,"parameterDefinitions": [{"name": "priority", "type": "INT", "default": 10},{"name": "sceneFile", "type": "STRING", "default": "/tmp/scene"},],"steps": [{"name": "CliScript","script": {"embeddedFiles": [{"name": "runScript","type": "TEXT","runnable": True,"data": '#!/usr/bin/env bash\n\necho "Running the task"\nsleep 35\n',}],"actions": {"onRun": {"command": "{{Task.File.runScript}}"}},},}],}) | 1 | 27 | 1 | 105 | 0 | 90 | 116 | 90 | job_name | [] | Returns | {"Return": 1} | 1 | 27 | 1 | ["json.dumps"] | 1 | ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_bundle_submit_py.test_cli_bundle_job_name"] | The function (get_minimal_json_job_template) defined within the public class called public.The function start at line 90 and ends at 116. It contains 27 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, It has 1.0 function called inside which is ["json.dumps"], 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_bundle_submit_py.test_cli_bundle_job_name"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle | def test_create_job_from_job_bundle(fresh_deadline_config, temp_job_bundle_dir, job_template_case, parameters_case):"""Test a matrix of different job template and parameters file cases."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.storage_profile_id", MOCK_STORAGE_PROFILE_ID)job_template_type, job_template = MOCK_JOB_TEMPLATE_CASES[job_template_case]parameters_type, parameters, expected_create_job_parameters = MOCK_PARAMETERS_CASES[parameters_case]with patch_calls_for_create_job_from_job_bundle() as mock:mock.get_boto3_client().get_storage_profile_for_queue.return_value = (MOCK_GET_STORAGE_PROFILE_FOR_QUEUE_RESPONSE)# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, f"template.{job_template_type.lower()}"),"w",encoding="utf8",) as f:f.write(job_template)# Write the parameter values to the job bundle, if the test case parameter includes themif parameters_type:with open(os.path.join(temp_job_bundle_dir, f"parameter_values.{parameters_type.lower()}"),"w",encoding="utf8",) as f:f.write(parameters)# This is the function under testresponse = api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],)# The response from the API is returned verbatimassert response == MOCK_JOB_IDexpected_create_job_parameters_dict: dict = dict(**expected_create_job_parameters)expected_create_job_parameters_dict["priority"] = expected_create_job_parameters_dict.get("priority", 50)mock.get_boto3_client().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=job_template,templateType=job_template_type,storageProfileId=MOCK_STORAGE_PROFILE_ID,**expected_create_job_parameters_dict,) | 2 | 44 | 4 | 215 | 1 | 294 | 349 | 294 | fresh_deadline_config,temp_job_bundle_dir,job_template_case,parameters_case | ['response'] | None | {"AnnAssign": 1, "Assign": 5, "Expr": 7, "If": 1, "With": 3} | 22 | 56 | 22 | ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "parameters_type.lower", "f.write", "api.create_job_from_job_bundle", "dict", "expected_create_job_parameters_dict.get", "create_job.assert_called_once_with", "mock.get_boto3_client", "pytest.mark.parametrize", "MOCK_JOB_TEMPLATE_CASES.keys", "pytest.mark.parametrize", "MOCK_PARAMETERS_CASES.keys"] | 0 | [] | The function (test_create_job_from_job_bundle) defined within the public class called public.The function start at line 294 and ends at 349. It contains 44 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [294.0] and does not return any value. It declares 22.0 functions, and It has 22.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "parameters_type.lower", "f.write", "api.create_job_from_job_bundle", "dict", "expected_create_job_parameters_dict.get", "create_job.assert_called_once_with", "mock.get_boto3_client", "pytest.mark.parametrize", "MOCK_JOB_TEMPLATE_CASES.keys", "pytest.mark.parametrize", "MOCK_PARAMETERS_CASES.keys"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_error_missing_template | def test_create_job_from_job_bundle_error_missing_template(fresh_deadline_config, temp_job_bundle_dir):"""Test a job bundle with missing template."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)with patch_calls_for_create_job_from_job_bundle():# Don't write a template file# Write the parameters to the job bundle, if the test case parameter includes themwith open(os.path.join(temp_job_bundle_dir, "parameter_values.json"), "w", encoding="utf8") as f:f.write(MOCK_PARAMETERS_CASES["DEADLINE_ONLY_JSON"][1])# This is the function under testwith pytest.raises(exceptions.DeadlineOperationError):api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],) | 1 | 15 | 2 | 88 | 0 | 352 | 375 | 352 | fresh_deadline_config,temp_job_bundle_dir | [] | None | {"Expr": 5, "With": 3} | 8 | 24 | 8 | ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"] | 0 | [] | The function (test_create_job_from_job_bundle_error_missing_template) defined within the public class called public.The function start at line 352 and ends at 375. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [352.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_error_duplicate_template | def test_create_job_from_job_bundle_error_duplicate_template(fresh_deadline_config, temp_job_bundle_dir):"""Test a job bundle with both a JSON and YAML template."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)with patch_calls_for_create_job_from_job_bundle():# Write both a JSON and YAML template filewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])with open(os.path.join(temp_job_bundle_dir, "template.yaml"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_YAML"][1])# Write the parameters to the job bundlewith open(os.path.join(temp_job_bundle_dir, "parameter_values.json"), "w", encoding="utf8") as f:f.write(MOCK_PARAMETERS_CASES["DEADLINE_ONLY_JSON"][1])# This is the function under testwith pytest.raises(exceptions.DeadlineOperationError):api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],) | 1 | 19 | 2 | 158 | 0 | 378 | 405 | 378 | fresh_deadline_config,temp_job_bundle_dir | [] | None | {"Expr": 7, "With": 5} | 14 | 28 | 14 | ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"] | 0 | [] | The function (test_create_job_from_job_bundle_error_duplicate_template) defined within the public class called public.The function start at line 378 and ends at 405. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [378.0] and does not return any value. It declares 14.0 functions, and It has 14.0 functions called inside which are ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_error_duplicate_parameters | def test_create_job_from_job_bundle_error_duplicate_parameters(fresh_deadline_config, temp_job_bundle_dir):"""Test a job bundle with an incorrect AWS Deadline Cloud parameter"""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)with patch_calls_for_create_job_from_job_bundle():# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Write the parameters file with a nonexistent AWS Deadline Cloud parameterwith open(os.path.join(temp_job_bundle_dir, "parameter_values.json"), "w", encoding="utf8") as f:f.write(MOCK_PARAMETERS_JSON_NONEXISTENT_DEADLINE_PARAMETER)# This is the function under testwith pytest.raises(exceptions.DeadlineOperationError):api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],) | 1 | 17 | 2 | 117 | 0 | 408 | 433 | 408 | fresh_deadline_config,temp_job_bundle_dir | [] | None | {"Expr": 6, "With": 4} | 11 | 26 | 11 | ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"] | 0 | [] | The function (test_create_job_from_job_bundle_error_duplicate_parameters) defined within the public class called public.The function start at line 408 and ends at 433. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [408.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "pytest.raises", "api.create_job_from_job_bundle"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_job_attachments.fake_hashing_callback | def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 476 | 477 | 476 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_job_attachments.fake_hashing_callback) defined within the public class called public.The function start at line 476 and ends at 477. 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_create_job_from_job_bundle_job_attachments.fake_upload_callback | def fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 479 | 480 | 479 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_job_attachments.fake_upload_callback) defined within the public class called public.The function start at line 479 and ends at 480. 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_create_job_from_job_bundle_job_attachments | def test_create_job_from_job_bundle_job_attachments(fresh_deadline_config, temp_job_bundle_dir, temp_assets_dir):"""Test a job bundle with asset references."""with patch_calls_for_create_job_from_job_bundle() as mock:mock.get_boto3_client().get_storage_profile_for_queue.return_value = (MOCK_GET_STORAGE_PROFILE_FOR_QUEUE_RESPONSE)config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.storage_profile_id", MOCK_STORAGE_PROFILE_ID)# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Create some files in the assets dirasset_contents = {"asset-1.txt": "This is asset 1","somedir/asset-2.txt": "Asset 2","somedir/asset-3.bat": "@echo asset 3",}write_test_asset_files(temp_assets_dir, asset_contents)# Write the asset_references fileasset_references = {"inputs": {"filenames": [os.path.join(temp_assets_dir, "asset-1.txt")],"directories": [os.path.join(temp_assets_dir, "somedir")],},"outputs": {"directories": [os.path.join(temp_assets_dir, "somedir")]},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return Truedef fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True# This is the function we're testingapi.create_job_from_job_bundle(temp_job_bundle_dir,print_function_callback=print,hashing_progress_callback=fake_hashing_callback,upload_progress_callback=fake_upload_callback,queue_parameter_definitions=[],known_asset_paths=[temp_assets_dir],)mock.hash_attachments.assert_called_once_with(asset_manager=ANY,asset_groups=[AssetRootGroup(root_path=temp_assets_dir,inputs={Path(temp_assets_dir) / p for p in asset_contents.keys()},outputs={Path(temp_assets_dir) / "somedir"},)],total_input_files=3,total_input_bytes=35,print_function_callback=print,hashing_progress_callback=fake_hashing_callback,)mock.get_boto3_client().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",priority=50,storageProfileId=MOCK_STORAGE_PROFILE_ID,attachments=ANY,)mock_telemetry_client = mock.get_deadline_cloud_library_telemetry_client()assert mock_telemetry_client.record_hashing_summary.call_count == 1assert mock_telemetry_client.record_upload_summary.call_count == 1assert mock_telemetry_client.record_event.mock_calls == [call(event_type="com.amazon.rum.deadline.submission",event_details={"submitter_name": "Custom"},from_gui=False,),call(event_type="com.amazon.rum.deadline.create_job",event_details={"is_success": True},from_gui=False,),] | 2 | 77 | 3 | 418 | 3 | 436 | 529 | 436 | fresh_deadline_config,temp_job_bundle_dir,temp_assets_dir | ['asset_references', 'mock_telemetry_client', 'asset_contents'] | Returns | {"Assign": 4, "Expr": 10, "Return": 2, "With": 3} | 26 | 94 | 26 | ["patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "os.path.join", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock.hash_attachments.assert_called_once_with", "AssetRootGroup", "Path", "asset_contents.keys", "Path", "create_job.assert_called_once_with", "mock.get_boto3_client", "mock.get_deadline_cloud_library_telemetry_client", "call", "call"] | 0 | [] | The function (test_create_job_from_job_bundle_job_attachments) defined within the public class called public.The function start at line 436 and ends at 529. It contains 77 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [436.0], and this function return a value. It declares 26.0 functions, and It has 26.0 functions called inside which are ["patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "os.path.join", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock.hash_attachments.assert_called_once_with", "AssetRootGroup", "Path", "asset_contents.keys", "Path", "create_job.assert_called_once_with", "mock.get_boto3_client", "mock.get_deadline_cloud_library_telemetry_client", "call", "call"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_empty_job_attachments.fake_hashing_callback | def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 580 | 581 | 580 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_empty_job_attachments.fake_hashing_callback) defined within the public class called public.The function start at line 580 and ends at 581. 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_create_job_from_job_bundle_empty_job_attachments.fake_upload_callback | def fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 583 | 584 | 583 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_empty_job_attachments.fake_upload_callback) defined within the public class called public.The function start at line 583 and ends at 584. 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_create_job_from_job_bundle_empty_job_attachments | def test_create_job_from_job_bundle_empty_job_attachments(fresh_deadline_config, temp_job_bundle_dir, temp_assets_dir):"""Test that when we have asset references that do not fall under Job Attachments(for example, if under a SHARED Storage Profile Filesystem Location), no JobAttachments calls are made."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.storage_profile_id", MOCK_STORAGE_PROFILE_ID)with patch_calls_for_create_job_from_job_bundle() as mock, patch.object(S3AssetManager,"prepare_paths_for_upload",) as mock_prepare_paths:mock.get_boto3_client().get_storage_profile_for_queue.return_value = (MOCK_GET_STORAGE_PROFILE_FOR_QUEUE_RESPONSE)# When this function returns an empty object, we skip Job Attachments callsexpected_upload_group = AssetUploadGroup()mock_prepare_paths.return_value = expected_upload_group# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Create some files in the assets dirasset_contents = {"asset-1.txt": "This is asset 1","somedir/asset-2.txt": "Asset 2","somedir/asset-3.bat": "@echo asset 3",}write_test_asset_files(temp_assets_dir, asset_contents)# Write the asset_references fileasset_references = {"inputs": {"filenames": [os.path.join(temp_assets_dir, "asset-1.txt")],"directories": [os.path.join(temp_assets_dir, "somedir")],},"outputs": {"directories": [os.path.join(temp_assets_dir, "somedir")]},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return Truedef fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True# This is the function we're testingapi.create_job_from_job_bundle(temp_job_bundle_dir,print_function_callback=print,hashing_progress_callback=fake_hashing_callback,upload_progress_callback=fake_upload_callback,queue_parameter_definitions=[],)mock_prepare_paths.assert_called_once_with(input_paths=sorted([os.path.join(temp_assets_dir, "asset-1.txt"),os.path.join(temp_assets_dir, os.path.normpath("somedir/asset-2.txt")),os.path.join(temp_assets_dir, os.path.normpath("somedir/asset-3.bat")),]),output_paths=[os.path.join(temp_assets_dir, "somedir")],referenced_paths=[],storage_profile=MOCK_STORAGE_PROFILE,require_paths_exist=False,)mock.hash_attachments.assert_not_called()mock.upload_assets.assert_not_called()# Should not be called with Job Attachmentsmock.get_boto3_client().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType=ANY,priority=50,storageProfileId=MOCK_STORAGE_PROFILE_ID,) | 1 | 66 | 3 | 391 | 3 | 532 | 618 | 532 | fresh_deadline_config,temp_job_bundle_dir,temp_assets_dir | ['asset_references', 'expected_upload_group', 'asset_contents'] | Returns | {"Assign": 5, "Expr": 12, "Return": 2, "With": 3} | 30 | 87 | 30 | ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "patch.object", "mock.get_boto3_client", "AssetUploadGroup", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "os.path.join", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock_prepare_paths.assert_called_once_with", "sorted", "os.path.join", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.join", "mock.hash_attachments.assert_not_called", "mock.upload_assets.assert_not_called", "create_job.assert_called_once_with", "mock.get_boto3_client"] | 0 | [] | The function (test_create_job_from_job_bundle_empty_job_attachments) defined within the public class called public.The function start at line 532 and ends at 618. It contains 66 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [532.0], and this function return a value. It declares 30.0 functions, and It has 30.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "patch.object", "mock.get_boto3_client", "AssetUploadGroup", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "os.path.join", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock_prepare_paths.assert_called_once_with", "sorted", "os.path.join", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.join", "mock.hash_attachments.assert_not_called", "mock.upload_assets.assert_not_called", "create_job.assert_called_once_with", "mock.get_boto3_client"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_with_empty_asset_references | def test_create_job_from_job_bundle_with_empty_asset_references(fresh_deadline_config, temp_job_bundle_dir):"""Test a job bundle with an asset_references file but no referenced files."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.storage_profile_id", MOCK_STORAGE_PROFILE_ID)job_template_type, job_template = MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"]with patch_calls_for_create_job_from_job_bundle() as mock:mock.get_boto3_client().get_storage_profile_for_queue.return_value = (MOCK_GET_STORAGE_PROFILE_FOR_QUEUE_RESPONSE)# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, f"template.{job_template_type.lower()}"),"w",encoding="utf8",) as f:f.write(job_template)# Write an asset_references.json file with empty listsasset_references: dict = {"inputs": {"filenames": [], "directories": []},"outputs": {"directories": []},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)# This is the function under testresponse = api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],)assert response == MOCK_JOB_ID# There should be no job attachments section in the resultmock.get_boto3_client().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=job_template,templateType=job_template_type,storageProfileId=MOCK_STORAGE_PROFILE_ID,priority=50,) | 1 | 38 | 2 | 210 | 1 | 621 | 670 | 621 | fresh_deadline_config,temp_job_bundle_dir | ['response'] | None | {"AnnAssign": 1, "Assign": 3, "Expr": 7, "With": 3} | 15 | 50 | 15 | ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "create_job.assert_called_once_with", "mock.get_boto3_client"] | 0 | [] | The function (test_create_job_from_job_bundle_with_empty_asset_references) defined within the public class called public.The function start at line 621 and ends at 670. It contains 38 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [621.0] and does not return any value. It declares 15.0 functions, and It has 15.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "create_job.assert_called_once_with", "mock.get_boto3_client"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_partially_empty_directories | def test_create_job_from_job_bundle_partially_empty_directories(fresh_deadline_config, temp_job_bundle_dir):"""Test a job bundle with an input directory that contains both empty directories and input filesdoes not throw a MisconfiguredInputsError and successfully submits"""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)job_template_type, job_template = MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"]temp_bundle_dir_as_path = Path(temp_job_bundle_dir)assets_directory: str = str(temp_bundle_dir_as_path / "assets")empty_directory = str(temp_bundle_dir_as_path / "assets" / "empty_dir")Path(empty_directory).mkdir(parents=True)(temp_bundle_dir_as_path / "assets" / "input_file").touch()with patch_calls_for_create_job_from_job_bundle():# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, f"template.{job_template_type.lower()}"),"w",encoding="utf8",) as f:f.write(job_template)# Write an asset_references.jsonasset_references: dict = {"inputs": {"filenames": [], "directories": [assets_directory]},"outputs": {"directories": []},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)# WHENresponse = api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],)# THEN# create_job_from_job_bundle did NOT throw MisconfiguredInputsErrorassert response == MOCK_JOB_ID | 1 | 31 | 2 | 201 | 3 | 673 | 717 | 673 | fresh_deadline_config,temp_job_bundle_dir | ['temp_bundle_dir_as_path', 'empty_directory', 'response'] | None | {"AnnAssign": 2, "Assign": 4, "Expr": 7, "With": 3} | 17 | 45 | 17 | ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "touch", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle"] | 0 | [] | The function (test_create_job_from_job_bundle_partially_empty_directories) defined within the public class called public.The function start at line 673 and ends at 717. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [673.0] and does not return any value. It declares 17.0 functions, and It has 17.0 functions called inside which are ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "touch", "patch_calls_for_create_job_from_job_bundle", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_misconfigured_directories | def test_create_job_from_job_bundle_misconfigured_directories(fresh_deadline_config, temp_job_bundle_dir, caplog):"""Test that a submitting a job with the `require_paths_exist` flag set to truewith a job bundle with input directories that do not exist throws an error.Also confirms that empty directories as logged and added to referenced paths."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)job_template_type, job_template = MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"]temp_bundle_dir_as_path = Path(temp_job_bundle_dir)missing_directory = str(temp_bundle_dir_as_path / "does" / "not" / "exist" / "bad_path")empty_directory = str(temp_bundle_dir_as_path / "empty_dir")Path(empty_directory).mkdir()with patch_calls_for_create_job_from_job_bundle():caplog.set_level(INFO)# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, f"template.{job_template_type.lower()}"),"w",encoding="utf8",) as f:f.write(job_template)# Write an asset_references.jsonasset_references: dict = {"inputs": {"filenames": [], "directories": [missing_directory, empty_directory]},"outputs": {"directories": []},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)# WHEN / THENwith pytest.raises(MisconfiguredInputsError) as execinfo:api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],require_paths_exist=True,)assert "bad_path" in str(execinfo)assert "empty_dir" not in str(execinfo)assert "empty_dir' is empty. Adding to referenced paths." in caplog.text | 1 | 35 | 3 | 228 | 3 | 720 | 768 | 720 | fresh_deadline_config,temp_job_bundle_dir,caplog | ['temp_bundle_dir_as_path', 'missing_directory', 'empty_directory'] | None | {"AnnAssign": 1, "Assign": 4, "Expr": 8, "With": 4} | 20 | 49 | 20 | ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "patch_calls_for_create_job_from_job_bundle", "caplog.set_level", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "pytest.raises", "api.create_job_from_job_bundle", "str", "str"] | 0 | [] | The function (test_create_job_from_job_bundle_misconfigured_directories) defined within the public class called public.The function start at line 720 and ends at 768. It contains 35 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [720.0] and does not return any value. It declares 20.0 functions, and It has 20.0 functions called inside which are ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "patch_calls_for_create_job_from_job_bundle", "caplog.set_level", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "pytest.raises", "api.create_job_from_job_bundle", "str", "str"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_misconfigured_input_files | def test_create_job_from_job_bundle_misconfigured_input_files(fresh_deadline_config, temp_job_bundle_dir, caplog):"""Test that a submitting a job without the `require_paths_exist` flag set,with a job bundle with input directories that do not exist does not include thosedirectories in the warning message, but DOES incldue misconfigured directories thatwere specified as files, which should result in an error."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)job_template_type, job_template = MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"]temp_bundle_dir_as_path = Path(temp_job_bundle_dir)missing_file = str(temp_bundle_dir_as_path / "does" / "not" / "exist.png")directory_pretending_to_be_file = str(temp_bundle_dir_as_path / "sneaky_bad_not_file")Path(directory_pretending_to_be_file).mkdir()with patch_calls_for_create_job_from_job_bundle():caplog.set_level(INFO)# Write the template to the job bundlewith open(os.path.join(temp_job_bundle_dir, f"template.{job_template_type.lower()}"),"w",encoding="utf8",) as f:f.write(job_template)# Write an asset_references.jsonasset_references: dict = {"inputs": {"filenames": [missing_file, directory_pretending_to_be_file],"directories": [],},"outputs": {"directories": []},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)# WHEN / THENwith pytest.raises(MisconfiguredInputsError) as execinfo:api.create_job_from_job_bundle(job_bundle_dir=temp_job_bundle_dir,queue_parameter_definitions=[],)assert "sneaky_bad_not_file" in str(execinfo)assert "exist.png" not in str(execinfo)assert "exist.png' does not exist. Adding to referenced paths." in caplog.text | 1 | 37 | 3 | 223 | 3 | 771 | 822 | 771 | fresh_deadline_config,temp_job_bundle_dir,caplog | ['temp_bundle_dir_as_path', 'directory_pretending_to_be_file', 'missing_file'] | None | {"AnnAssign": 1, "Assign": 4, "Expr": 8, "With": 4} | 20 | 52 | 20 | ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "patch_calls_for_create_job_from_job_bundle", "caplog.set_level", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "pytest.raises", "api.create_job_from_job_bundle", "str", "str"] | 0 | [] | The function (test_create_job_from_job_bundle_misconfigured_input_files) defined within the public class called public.The function start at line 771 and ends at 822. It contains 37 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [771.0] and does not return any value. It declares 20.0 functions, and It has 20.0 functions called inside which are ["config.set_setting", "config.set_setting", "Path", "str", "str", "mkdir", "Path", "patch_calls_for_create_job_from_job_bundle", "caplog.set_level", "open", "os.path.join", "job_template_type.lower", "f.write", "open", "os.path.join", "json.dump", "pytest.raises", "api.create_job_from_job_bundle", "str", "str"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_with_single_asset_file.fake_hashing_callback | def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 862 | 863 | 862 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_with_single_asset_file.fake_hashing_callback) defined within the public class called public.The function start at line 862 and ends at 863. 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_create_job_from_job_bundle_with_single_asset_file.fake_upload_callback | def fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True | 1 | 2 | 1 | 11 | 0 | 865 | 866 | 865 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_create_job_from_job_bundle_with_single_asset_file.fake_upload_callback) defined within the public class called public.The function start at line 865 and ends at 866. 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_create_job_from_job_bundle_with_single_asset_file | def test_create_job_from_job_bundle_with_single_asset_file(fresh_deadline_config, temp_job_bundle_dir, temp_assets_dir):"""Test a job bundle with a single input file reference and no output directories."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.storage_profile_id", MOCK_STORAGE_PROFILE_ID)# Use a temporary directory for the job bundlewith patch_calls_for_create_job_from_job_bundle() as mock:mock.get_boto3_client().get_storage_profile_for_queue.side_effect = [MOCK_GET_STORAGE_PROFILE_FOR_QUEUE_RESPONSE]# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Create some files in the assets dirasset_contents = {"asset-1.txt": "This is asset 1",}write_test_asset_files(temp_assets_dir, asset_contents)# Write the asset_references fileasset_references = {"inputs": {"filenames": [os.path.join(temp_assets_dir, "asset-1.txt")],},}with open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": asset_references}, f)def fake_hashing_callback(metadata: ProgressReportMetadata) -> bool:return Truedef fake_upload_callback(metadata: ProgressReportMetadata) -> bool:return True# This is the function we're testingapi.create_job_from_job_bundle(temp_job_bundle_dir,print_function_callback=print,hashing_progress_callback=fake_hashing_callback,upload_progress_callback=fake_upload_callback,queue_parameter_definitions=[],known_asset_paths=[temp_assets_dir],)mock.hash_attachments.assert_called_once_with(asset_manager=ANY,asset_groups=[AssetRootGroup(root_path=temp_assets_dir, inputs={Path(temp_assets_dir) / "asset-1.txt"})],total_input_files=1,total_input_bytes=15,print_function_callback=print,hashing_progress_callback=fake_hashing_callback,)assert mock.get_boto3_client().create_job.mock_calls == [call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType=ANY,priority=50,storageProfileId=MOCK_STORAGE_PROFILE_ID,attachments={"manifests": [{"rootPath": "/mnt/root/path1","rootPathFormat": PathFormat.POSIX,"inputManifestPath": "mock-manifest","inputManifestHash": "mock-manifest-hash","outputRelativeDirectories": ["."],},],"fileSystem": JobAttachmentsFileSystem.COPIED,},)] | 1 | 69 | 3 | 328 | 2 | 825 | 912 | 825 | fresh_deadline_config,temp_job_bundle_dir,temp_assets_dir | ['asset_references', 'asset_contents'] | Returns | {"Assign": 3, "Expr": 9, "Return": 2, "With": 3} | 19 | 88 | 19 | ["config.set_setting", "config.set_setting", "config.set_setting", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock.hash_attachments.assert_called_once_with", "AssetRootGroup", "Path", "mock.get_boto3_client", "call"] | 0 | [] | The function (test_create_job_from_job_bundle_with_single_asset_file) defined within the public class called public.The function start at line 825 and ends at 912. It contains 69 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [825.0], and this function return a 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_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "open", "os.path.join", "f.write", "write_test_asset_files", "os.path.join", "open", "os.path.join", "json.dump", "api.create_job_from_job_bundle", "mock.hash_attachments.assert_called_once_with", "AssetRootGroup", "Path", "mock.get_boto3_client", "call"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_with_target_task_run_status | def test_create_job_from_job_bundle_with_target_task_run_status(fresh_deadline_config,temp_job_bundle_dir,):"""Test that create_job_from_job_bundle passes the target_task_run_status parameter to create_job."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Create a minimal template file like other tests dowith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write('{"specificationVersion": "jobtemplate-2023-09", "name": "TestJob", "steps": []}')with patch_calls_for_create_job_from_job_bundle() as mock:api.create_job_from_job_bundle(temp_job_bundle_dir,target_task_run_status="SUSPENDED",queue_parameter_definitions=[],)# Verify that targetTaskRunStatus was passed to create_jobcreate_job_call = mock.get_boto3_client().create_job.call_argsassert create_job_call is not Noneassert create_job_call.kwargs["targetTaskRunStatus"] == "SUSPENDED" | 1 | 17 | 2 | 102 | 1 | 915 | 939 | 915 | fresh_deadline_config,temp_job_bundle_dir | ['create_job_call'] | None | {"Assign": 1, "Expr": 5, "With": 2} | 8 | 25 | 8 | ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "patch_calls_for_create_job_from_job_bundle", "api.create_job_from_job_bundle", "mock.get_boto3_client"] | 0 | [] | The function (test_create_job_from_job_bundle_with_target_task_run_status) defined within the public class called public.The function start at line 915 and ends at 939. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [915.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "patch_calls_for_create_job_from_job_bundle", "api.create_job_from_job_bundle", "mock.get_boto3_client"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_without_target_task_run_status | def test_create_job_from_job_bundle_without_target_task_run_status(fresh_deadline_config,temp_job_bundle_dir,):"""Test that create_job_from_job_bundle does not pass targetTaskRunStatus when not specified."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Create a minimal template file like other tests dowith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write('{"specificationVersion": "jobtemplate-2023-09", "name": "TestJob", "steps": []}')with patch_calls_for_create_job_from_job_bundle() as mock:api.create_job_from_job_bundle(temp_job_bundle_dir,queue_parameter_definitions=[],)# Verify that targetTaskRunStatus was not passed to create_jobcreate_job_call = mock.get_boto3_client().create_job.call_argsassert create_job_call is not Noneassert "targetTaskRunStatus" not in create_job_call.kwargs | 1 | 16 | 2 | 96 | 1 | 942 | 965 | 942 | fresh_deadline_config,temp_job_bundle_dir | ['create_job_call'] | None | {"Assign": 1, "Expr": 5, "With": 2} | 8 | 24 | 8 | ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "patch_calls_for_create_job_from_job_bundle", "api.create_job_from_job_bundle", "mock.get_boto3_client"] | 0 | [] | The function (test_create_job_from_job_bundle_without_target_task_run_status) defined within the public class called public.The function start at line 942 and ends at 965. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [942.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "patch_calls_for_create_job_from_job_bundle", "api.create_job_from_job_bundle", "mock.get_boto3_client"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_create_job_to_complete.mock_continue_callback | def mock_continue_callback() -> bool:return True | 1 | 2 | 0 | 8 | 0 | 1,003 | 1,004 | 1,003 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_create_job_to_complete.mock_continue_callback) defined within the public class called public.The function start at line 1003 and ends at 1004. 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_wait_for_create_job_to_complete | def test_wait_for_create_job_to_complete(responses, final_status):"""Test the waiter for calling CreateJob."""def mock_continue_callback() -> bool:return Truedeadline_client = Mock()deadline_client.get_job.side_effect = [{"lifecycleStatus": response,"lifecycleStatusMessage": MOCK_STATUS_MESSAGE,}for response in responses]with patch.object(time, "sleep"):success, status_message = api.wait_for_create_job_to_complete(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,deadline_client=deadline_client,continue_callback=mock_continue_callback,)assert success == final_statusassert status_message == MOCK_STATUS_MESSAGE | 2 | 20 | 2 | 84 | 1 | 998 | 1,025 | 998 | responses,final_status | ['deadline_client'] | Returns | {"Assign": 3, "Expr": 1, "Return": 1, "With": 1} | 4 | 28 | 4 | ["Mock", "patch.object", "api.wait_for_create_job_to_complete", "pytest.mark.parametrize"] | 0 | [] | The function (test_wait_for_create_job_to_complete) defined within the public class called public.The function start at line 998 and ends at 1025. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [998.0], and this function return a value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["Mock", "patch.object", "api.wait_for_create_job_to_complete", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_create_job_to_complete_timeout.mock_continue_callback | def mock_continue_callback() -> bool:return True | 1 | 2 | 0 | 8 | 0 | 1,033 | 1,034 | 1,033 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_create_job_to_complete_timeout.mock_continue_callback) defined within the public class called public.The function start at line 1033 and ends at 1034. 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_wait_for_create_job_to_complete_timeout | def test_wait_for_create_job_to_complete_timeout():"""Test the waiter for calling CreateJob when it times out."""def mock_continue_callback() -> bool:return Truedeadline_client = Mock()deadline_client.get_job.return_value = {"state": "CREATE_IN_PROGRESS","lifecycleStatusMessage": MOCK_STATUS_MESSAGE,}# Mock time.time to simulate timeout after a few iterationsmock_times = [0,0.5,1.5,3.5,7.5,12.5,17.5,22.5,27.5,32.5,301,]# Last value exceeds 300s timeoutwith pytest.raises(TimeoutError), patch.object(time, "sleep"), patch.object(time, "time", side_effect=mock_times):api.wait_for_create_job_to_complete(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,deadline_client=deadline_client,continue_callback=mock_continue_callback,) | 1 | 30 | 0 | 127 | 2 | 1,028 | 1,065 | 1,028 | ['mock_times', 'deadline_client'] | Returns | {"Assign": 3, "Expr": 2, "Return": 1, "With": 1} | 5 | 38 | 5 | ["Mock", "pytest.raises", "patch.object", "patch.object", "api.wait_for_create_job_to_complete"] | 0 | [] | The function (test_wait_for_create_job_to_complete_timeout) defined within the public class called public.The function start at line 1028 and ends at 1065. It contains 30 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 ["Mock", "pytest.raises", "patch.object", "patch.object", "api.wait_for_create_job_to_complete"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_with_not_valid_directory_path | def test_create_job_from_job_bundle_with_not_valid_directory_path(fresh_deadline_config, temp_job_bundle_dir, temp_assets_dir, template, parameter_key, file_path):"""Tests that a job bundle with template that contains either absolute paths or relative paths that resolveoutside of the Job Bundle directory throws a DeadlineOperationError."""# Use a temporary directory for the job bundle# Define absolute paths for testing within temp_assets_dirjob_bundle_absolute_dir_path = os.path.normpath(temp_assets_dir + file_path)# Insert absolute paths with temp dir into job templatejob_template_replaced = template.replace(parameter_key, job_bundle_absolute_dir_path)# Write the YAML templatewith open(os.path.join(temp_job_bundle_dir, "template.yaml"), "w", encoding="utf8") as f:f.write(job_template_replaced)with patch.object(_submit_job_bundle.api, "get_boto3_session"), patch.object(_submit_job_bundle.api, "get_boto3_client") as client_mock, patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"):client_mock().create_job.side_effect = [MOCK_CREATE_JOB_RESPONSE]client_mock().get_queue.side_effect = [MOCK_GET_QUEUE_RESPONSE]client_mock().get_job.side_effect = [MOCK_GET_JOB_RESPONSE]with pytest.raises(DeadlineOperationError,):# This is the function we're testingapi.create_job_from_job_bundle(temp_job_bundle_dir, job_parameters=[], queue_parameter_definitions=[]) | 1 | 19 | 6 | 161 | 2 | 211 | 241 | 211 | fresh_deadline_config,temp_job_bundle_dir,temp_assets_dir,template,parameter_key,file_path | ['job_template_replaced', 'job_bundle_absolute_dir_path'] | None | {"Assign": 5, "Expr": 3, "With": 3} | 18 | 31 | 18 | ["os.path.normpath", "template.replace", "open", "os.path.join", "f.write", "patch.object", "patch.object", "patch.object", "client_mock", "client_mock", "client_mock", "pytest.raises", "api.create_job_from_job_bundle", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param", "pytest.param"] | 0 | [] | The function (test_create_job_from_job_bundle_with_not_valid_directory_path) defined within the public class called public.The function start at line 211 and ends at 241. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [211.0] and does not return any value. It declares 18.0 functions, and It has 18.0 functions called inside which are ["os.path.normpath", "template.replace", "open", "os.path.join", "f.write", "patch.object", "patch.object", "patch.object", "client_mock", "client_mock", "client_mock", "pytest.raises", "api.create_job_from_job_bundle", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param", "pytest.param"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_create_job_from_job_bundle_with_all_asset_ref_variants | def test_create_job_from_job_bundle_with_all_asset_ref_variants(fresh_deadline_config, temp_job_bundle_dir, temp_assets_dir, temp_cwd):"""Test a job bundle with template from JOB_TEMPLATE_ALL_ASSET_REF_VARIANTS."""# Use a temporary directory for the job bundlewith patch.object(_submit_job_bundle.api, "get_boto3_session"), patch.object(_submit_job_bundle.api, "get_boto3_client") as client_mock, patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"), patch.object(S3AssetManager, "hash_assets_and_create_manifest") as mock_hash_assets, patch.object(S3AssetManager, "upload_assets") as mock_upload_assets, patch.object(_submit_job_bundle.api, "get_deadline_cloud_library_telemetry_client"):client_mock().create_job.side_effect = [MOCK_CREATE_JOB_RESPONSE]client_mock().get_queue.side_effect = [MOCK_GET_QUEUE_RESPONSE]client_mock().get_job.side_effect = [MOCK_GET_JOB_RESPONSE]mock_hash_assets.return_value = [SummaryStatistics(), AssetRootManifest()]mock_upload_assets.return_value = [SummaryStatistics(),Attachments([ManifestProperties(rootPath="/mnt/root/path1",rootPathFormat=PathFormat.POSIX,inputManifestPath="mock-manifest",inputManifestHash="mock-manifest-hash",outputRelativeDirectories=["."],),],),]config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Write the YAML templatewith open(os.path.join(temp_job_bundle_dir, "template.yaml"), "w", encoding="utf8") as f:f.write(JOB_TEMPLATE_ALL_ASSET_REF_VARIANTS)job_parameters = [{"name": "FileNoneDefault","value": os.path.join(temp_assets_dir, "file/inside/asset-dir-filenonedefault.txt"),},{"name": "FileNone","value": os.path.join(temp_assets_dir, "file/inside/asset-dir-filenone.txt"),},# Leaving out "FileIn" so it gets the default value{"name": "FileOut", "value": "./file/inside/cwd.txt"},{"name": "FileInout","value": os.path.join(temp_assets_dir, "file/inside/asset-dir-fileinout.txt"),},{"name": "DirNoneDefault","value": os.path.join(temp_assets_dir, "./dir/inside/asset-dir-dirnonedefault"),},{"name": "DirNone","value": os.path.join(temp_assets_dir, "./dir/inside/asset-dir-dirnone"),},# Leaving out "DirIn" so it gets the default value{"name": "DirOut", "value": "./dir/inside/cwd-dirout"},{"name": "DirInout","value": os.path.join(temp_assets_dir, "./dir/inside/asset-dir-dirinout"),},]# Write file contents to the job bundle dirwrite_test_asset_files(temp_job_bundle_dir,{JOB_BUNDLE_RELATIVE_FILE_PATH: "file in",JOB_BUNDLE_RELATIVE_DIR_PATH + "/file1.txt": "dir in file1",JOB_BUNDLE_RELATIVE_DIR_PATH + "/subdir/file1.txt": "dir in file2",},)# Write file contents to the temporary assets dirwrite_test_asset_files(temp_assets_dir,{"file/inside/asset-dir-fileinout.txt": "file inout","././dir/inside/asset-dir-dirinout/file_x.txt": "dir inout","././dir/inside/asset-dir-dirinout/subdir/file_y.txt": "dir inout",},)# This is the function we're testingapi.create_job_from_job_bundle(temp_job_bundle_dir,job_parameters=job_parameters,queue_parameter_definitions=[],known_asset_paths=[temp_assets_dir,os.path.join(os.getcwd(), "dir", "inside"),os.path.join(os.getcwd(), "file", "inside"),],)# The values of input_paths and output_paths are the first# thing this test needs to verify, confirming that the# bundle dir is used for default parameter values, and the# current working directory is used for job parameters.mock_hash_assets.assert_called_once_with(asset_groups=[AssetRootGroup(root_path=os.path.commonpath([os.getcwd(), temp_job_bundle_dir, temp_assets_dir]),inputs={Path(temp_job_bundle_dir) / "dir" / "inside" / "job_bundle" / "file1.txt",Path(temp_job_bundle_dir)/ "dir"/ "inside"/ "job_bundle"/ "subdir"/ "file1.txt",Path(temp_job_bundle_dir) / "file" / "inside" / "job_bundle.txt",Path(temp_assets_dir)/ "dir"/ "inside"/ "asset-dir-dirinout"/ "subdir"/ "file_y.txt",Path(temp_assets_dir)/ "dir"/ "inside"/ "asset-dir-dirinout"/ "file_x.txt",Path(temp_assets_dir) / "file" / "inside" / "asset-dir-fileinout.txt",},outputs={Path(os.path.join(os.getcwd(), "dir", "inside", "cwd-dirout")),Path(os.path.join(os.getcwd(), "file", "inside")),Path(temp_assets_dir) / "file" / "inside",Path(temp_assets_dir) / "dir" / "inside" / "asset-dir-dirinout",},references={Path(temp_assets_dir) / "file" / "inside" / "asset-dir-filenone.txt",Path(temp_assets_dir) / "file" / "inside" / "asset-dir-filenonedefault.txt",Path(temp_assets_dir) / "dir" / "inside" / "asset-dir-dirnone",Path(temp_assets_dir) / "dir" / "inside" / "asset-dir-dirnonedefault",},),],total_input_files=6,total_input_bytes=59,hash_cache_dir=os.path.expanduser(os.path.join("~", ".deadline", "cache")),on_preparing_to_submit=ANY,)client_mock().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="YAML",priority=50,attachments={"manifests": [{"rootPath": "/mnt/root/path1","rootPathFormat": PathFormat.POSIX,"inputManifestPath": "mock-manifest","inputManifestHash": "mock-manifest-hash","outputRelativeDirectories": ["."],},],"fileSystem": JobAttachmentsFileSystem.COPIED.value,},# The job parameter values are the second thing this test needs to verify,# confirming that the parameters were processed according to their types.parameters={"FileNoneDefault": {"path": os.path.join(temp_assets_dir, "file", "inside", "asset-dir-filenonedefault.txt"),},"FileNone": {"path": os.path.normpath(os.path.join(temp_assets_dir, "file", "inside", "asset-dir-filenone.txt"))},"FileOut": {"path": os.path.normpath(os.path.abspath("file/inside/cwd.txt"))},"FileIn": {"path": os.path.normpath(temp_job_bundle_dir + "/file/inside/job_bundle.txt")},"FileInout": {"path": os.path.normpath(temp_assets_dir + "/file/inside/asset-dir-fileinout.txt")},"DirNoneDefault": {"path": os.path.join(temp_assets_dir, "dir", "inside", "asset-dir-dirnonedefault"),},"DirNone": {"path": os.path.join(temp_assets_dir, "dir", "inside", "asset-dir-dirnone")},"DirIn": {"path": os.path.normpath(os.path.join(temp_job_bundle_dir, "dir", "inside", "job_bundle"))},"DirOut": {"path": os.path.normpath(os.path.abspath("dir/inside/cwd-dirout"))},"DirInout": {"path": os.path.normpath(os.path.join(temp_assets_dir, "dir", "inside", "asset-dir-dirinout"))},},) | 1 | 196 | 4 | 1,036 | 1 | 244 | 461 | 244 | fresh_deadline_config,temp_job_bundle_dir,temp_assets_dir,temp_cwd | ['job_parameters'] | None | {"Assign": 6, "Expr": 9, "With": 2} | 73 | 218 | 73 | ["patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "client_mock", "client_mock", "client_mock", "SummaryStatistics", "AssetRootManifest", "SummaryStatistics", "Attachments", "ManifestProperties", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "write_test_asset_files", "write_test_asset_files", "api.create_job_from_job_bundle", "os.path.join", "os.getcwd", "os.path.join", "os.getcwd", "mock_hash_assets.assert_called_once_with", "AssetRootGroup", "os.path.commonpath", "os.getcwd", "Path", "Path", "Path", "Path", "Path", "Path", "Path", "os.path.join", "os.getcwd", "Path", "os.path.join", "os.getcwd", "Path", "Path", "Path", "Path", "Path", "Path", "os.path.expanduser", "os.path.join", "create_job.assert_called_once_with", "client_mock", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.abspath", "os.path.normpath", "os.path.normpath", "os.path.join", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.abspath", "os.path.normpath", "os.path.join"] | 0 | [] | The function (test_create_job_from_job_bundle_with_all_asset_ref_variants) defined within the public class called public.The function start at line 244 and ends at 461. It contains 196 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [244.0] and does not return any value. It declares 73.0 functions, and It has 73.0 functions called inside which are ["patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "client_mock", "client_mock", "client_mock", "SummaryStatistics", "AssetRootManifest", "SummaryStatistics", "Attachments", "ManifestProperties", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "os.path.join", "write_test_asset_files", "write_test_asset_files", "api.create_job_from_job_bundle", "os.path.join", "os.getcwd", "os.path.join", "os.getcwd", "mock_hash_assets.assert_called_once_with", "AssetRootGroup", "os.path.commonpath", "os.getcwd", "Path", "Path", "Path", "Path", "Path", "Path", "Path", "os.path.join", "os.getcwd", "Path", "os.path.join", "os.getcwd", "Path", "Path", "Path", "Path", "Path", "Path", "os.path.expanduser", "os.path.join", "create_job.assert_called_once_with", "client_mock", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.abspath", "os.path.normpath", "os.path.normpath", "os.path.join", "os.path.join", "os.path.normpath", "os.path.join", "os.path.normpath", "os.path.abspath", "os.path.normpath", "os.path.join"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_success | def test_wait_for_job_completion_success():"""Test that wait_for_job_completion works correctly when job succeeds."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# First call returns RUNNING, second call returns SUCCEEDEDdeadline_mock.get_job.side_effect = [MOCK_JOB_RUNNING, MOCK_JOB_SUCCEEDED]# Mock time.sleep to avoid waiting in testswith patch("time.sleep"):# Mock datetime.now to simulate elapsed timestart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 12, 0, 10)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, end_time]result = wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=1,)assert isinstance(result, JobCompletionResult)assert result.status == "SUCCEEDED"assert result.elapsed_time == pytest.approx(10.0)assert len(result.failed_tasks) == 0# Verify the correct parameters were useddeadline_mock.get_job.assert_called_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID) | 1 | 23 | 0 | 169 | 4 | 97 | 132 | 97 | ['start_time', 'result', 'deadline_mock', 'end_time'] | None | {"Assign": 7, "Expr": 2, "With": 3} | 11 | 36 | 11 | ["patch", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_job.assert_called_with"] | 0 | [] | The function (test_wait_for_job_completion_success) defined within the public class called public.The function start at line 97 and ends at 132. It contains 23 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 11.0 functions, and It has 11.0 functions called inside which are ["patch", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_job.assert_called_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_failure.get_paginator_side_effect | def get_paginator_side_effect(operation):if operation == "list_steps":return steps_paginator_mockelif operation == "list_tasks":return tasks_paginator_mockreturn MagicMock() | 3 | 6 | 1 | 23 | 0 | 155 | 160 | 155 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_job_completion_failure.get_paginator_side_effect) defined within the public class called public.The function start at line 155 and ends at 160. It contains 6 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_failure | def test_wait_for_job_completion_failure():"""Test that wait_for_job_completion works correctly when job fails."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# First call returns RUNNING, second call returns FAILEDdeadline_mock.get_job.side_effect = [MOCK_JOB_RUNNING, MOCK_JOB_FAILED]# Set up paginator mock for list_stepssteps_paginator_mock = MagicMock()steps_paginator_mock.paginate.return_value = [MOCK_STEPS]# Set up paginator mock for list_taskstasks_paginator_mock = MagicMock()tasks_paginator_mock.paginate.return_value = [MOCK_TASKS]# Configure get_paginator to return the appropriate paginator based on the operationdef get_paginator_side_effect(operation):if operation == "list_steps":return steps_paginator_mockelif operation == "list_tasks":return tasks_paginator_mockreturn MagicMock()deadline_mock.get_paginator.side_effect = get_paginator_side_effect# Mock time.sleep to avoid waiting in testswith patch("time.sleep"):# Mock datetime.now to simulate elapsed timestart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 12, 0, 15)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, end_time]result = wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=1,)assert isinstance(result, JobCompletionResult)assert result.status == "FAILED"assert result.elapsed_time == pytest.approx(15.0)assert len(result.failed_tasks) == 2# Verify the failed tasks have the correct dataassert result.failed_tasks[0].step_id == "step-456"assert result.failed_tasks[0].task_id == "task-123"assert result.failed_tasks[0].step_name == "Step 2"assert result.failed_tasks[0].session_id == "session-abc123"assert result.failed_tasks[1].step_id == "step-456"assert result.failed_tasks[1].task_id == "task-456"assert result.failed_tasks[1].step_name == "Step 2"assert result.failed_tasks[1].session_id == "session-def456"# Verify paginators were called with correct parametersdeadline_mock.get_paginator.assert_any_call("list_steps")steps_paginator_mock.paginate.assert_called_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID)deadline_mock.get_paginator.assert_any_call("list_tasks")tasks_paginator_mock.paginate.assert_called_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID, stepId="step-456") | 1 | 42 | 0 | 332 | 6 | 135 | 205 | 135 | ['tasks_paginator_mock', 'end_time', 'result', 'deadline_mock', 'start_time', 'steps_paginator_mock'] | Returns | {"Assign": 12, "Expr": 5, "If": 2, "Return": 3, "With": 3} | 17 | 71 | 17 | ["patch", "MagicMock", "MagicMock", "MagicMock", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_paginator.assert_any_call", "steps_paginator_mock.paginate.assert_called_with", "deadline_mock.get_paginator.assert_any_call", "tasks_paginator_mock.paginate.assert_called_with"] | 0 | [] | The function (test_wait_for_job_completion_failure) defined within the public class called public.The function start at line 135 and ends at 205. It contains 42 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 17.0 functions, and It has 17.0 functions called inside which are ["patch", "MagicMock", "MagicMock", "MagicMock", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_paginator.assert_any_call", "steps_paginator_mock.paginate.assert_called_with", "deadline_mock.get_paginator.assert_any_call", "tasks_paginator_mock.paginate.assert_called_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_timeout | def test_wait_for_job_completion_timeout():"""Test that wait_for_job_completion times out correctly."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# Always return RUNNING to trigger timeoutdeadline_mock.get_job.return_value = MOCK_JOB_RUNNING# Mock time.sleep to avoid waiting in testswith patch("time.sleep"):# Mock datetime.now to simulate time passing beyond timeoutstart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)check_time = datetime.datetime(2023, 1, 1, 12, 0, 3)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, check_time]with patch.object(dt_mock, "now", side_effect=[start_time, check_time]):try:wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=1,timeout=2,)assert False, "Expected DeadlineOperationError was not raised"except DeadlineOperationError as e:assert "Timeout waiting for job" in str(e) | 2 | 22 | 0 | 150 | 3 | 208 | 239 | 208 | ['start_time', 'deadline_mock', 'check_time'] | None | {"Assign": 6, "Expr": 2, "Try": 1, "With": 4} | 9 | 32 | 9 | ["patch", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "patch.object", "wait_for_job_completion", "str"] | 0 | [] | The function (test_wait_for_job_completion_timeout) defined within the public class called public.The function start at line 208 and ends at 239. It contains 22 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 9.0 functions, and It has 9.0 functions called inside which are ["patch", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "patch.object", "wait_for_job_completion", "str"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_with_pagination.get_paginator_side_effect | def get_paginator_side_effect(operation):if operation == "list_steps":return steps_paginator_mockelif operation == "list_tasks":return tasks_paginator_mockreturn MagicMock() | 3 | 6 | 1 | 23 | 0 | 266 | 271 | 266 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_job_completion_with_pagination.get_paginator_side_effect) defined within the public class called public.The function start at line 266 and ends at 271. It contains 6 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_with_pagination | def test_wait_for_job_completion_with_pagination():"""Test that wait_for_job_completion correctly handles pagination for steps and tasks."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# Return FAILED job statusdeadline_mock.get_job.return_value = MOCK_JOB_FAILED# Set up paginator mock for list_steps with multiple pagessteps_page1 = {"steps": [MOCK_STEPS["steps"][0]]}steps_page2 = {"steps": [MOCK_STEPS["steps"][1]]}steps_paginator_mock = MagicMock()steps_paginator_mock.paginate.return_value = [steps_page1, steps_page2]# Set up paginator mock for list_tasks with multiple pagestasks_page1 = {"tasks": [MOCK_TASKS["tasks"][0]]}tasks_page2 = {"tasks": [MOCK_TASKS["tasks"][1], MOCK_TASKS["tasks"][2]]}tasks_paginator_mock = MagicMock()tasks_paginator_mock.paginate.return_value = [tasks_page1, tasks_page2]# Configure get_paginator to return the appropriate paginator based on the operationdef get_paginator_side_effect(operation):if operation == "list_steps":return steps_paginator_mockelif operation == "list_tasks":return tasks_paginator_mockreturn MagicMock()deadline_mock.get_paginator.side_effect = get_paginator_side_effect# Mock time.sleep to avoid waiting in testswith patch("time.sleep"):# Mock datetime.now to simulate elapsed timestart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 12, 0, 5)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, end_time]result = wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=1,)assert isinstance(result, JobCompletionResult)assert result.status == "FAILED"assert result.elapsed_time == pytest.approx(5.0)assert len(result.failed_tasks) == 2# Verify paginators were called with correct parametersdeadline_mock.get_paginator.assert_any_call("list_steps")steps_paginator_mock.paginate.assert_called_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID)deadline_mock.get_paginator.assert_any_call("list_tasks")tasks_paginator_mock.paginate.assert_called_with(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, jobId=MOCK_JOB_ID, stepId="step-456") | 1 | 38 | 0 | 312 | 10 | 242 | 305 | 242 | ['tasks_paginator_mock', 'end_time', 'result', 'tasks_page1', 'tasks_page2', 'deadline_mock', 'steps_page2', 'steps_page1', 'steps_paginator_mock', 'start_time'] | Returns | {"Assign": 16, "Expr": 5, "If": 2, "Return": 3, "With": 3} | 17 | 64 | 17 | ["patch", "MagicMock", "MagicMock", "MagicMock", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_paginator.assert_any_call", "steps_paginator_mock.paginate.assert_called_with", "deadline_mock.get_paginator.assert_any_call", "tasks_paginator_mock.paginate.assert_called_with"] | 0 | [] | The function (test_wait_for_job_completion_with_pagination) defined within the public class called public.The function start at line 242 and ends at 305. It contains 38 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 17.0 functions, and It has 17.0 functions called inside which are ["patch", "MagicMock", "MagicMock", "MagicMock", "MagicMock", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "pytest.approx", "len", "deadline_mock.get_paginator.assert_any_call", "steps_paginator_mock.paginate.assert_called_with", "deadline_mock.get_paginator.assert_any_call", "tasks_paginator_mock.paginate.assert_called_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_exponential_backoff.mock_sleep | def mock_sleep(interval):sleep_intervals.append(interval) | 1 | 2 | 1 | 11 | 0 | 351 | 352 | 351 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_job_completion_exponential_backoff.mock_sleep) defined within the public class called public.The function start at line 351 and ends at 352. 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_wait_for_job_completion_exponential_backoff | def test_wait_for_job_completion_exponential_backoff():"""Test that wait_for_job_completion uses exponential backoff correctly."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# Return RUNNING for several calls, then SUCCEEDEDdeadline_mock.get_job.side_effect = [MOCK_JOB_RUNNING,MOCK_JOB_RUNNING,MOCK_JOB_RUNNING,MOCK_JOB_SUCCEEDED,]# Mock time.sleep to track the intervalssleep_intervals = []def mock_sleep(interval):sleep_intervals.append(interval)with patch("time.sleep", side_effect=mock_sleep):# Mock datetime.now to simulate elapsed timestart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 12, 0, 10)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, end_time]result = wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=10,)assert isinstance(result, JobCompletionResult)assert result.status == "SUCCEEDED"# Verify exponential backoff: 0.5, 1.0, 2.0assert len(sleep_intervals) == pytest.approx(3)assert sleep_intervals[0] == pytest.approx(0.5)assert sleep_intervals[1] == pytest.approx(1.0)assert sleep_intervals[2] == pytest.approx(2.0) | 1 | 29 | 0 | 198 | 5 | 332 | 376 | 332 | ['end_time', 'sleep_intervals', 'deadline_mock', 'start_time', 'result'] | None | {"Assign": 8, "Expr": 2, "With": 3} | 14 | 45 | 14 | ["patch", "MagicMock", "sleep_intervals.append", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "len", "pytest.approx", "pytest.approx", "pytest.approx", "pytest.approx"] | 0 | [] | The function (test_wait_for_job_completion_exponential_backoff) defined within the public class called public.The function start at line 332 and ends at 376. It contains 29 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 14.0 functions, and It has 14.0 functions called inside which are ["patch", "MagicMock", "sleep_intervals.append", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "len", "pytest.approx", "pytest.approx", "pytest.approx", "pytest.approx"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_wait_for_job_completion_max_interval_cap.mock_sleep | def mock_sleep(interval):sleep_intervals.append(interval) | 1 | 2 | 1 | 11 | 0 | 393 | 394 | 393 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_wait_for_job_completion_max_interval_cap.mock_sleep) defined within the public class called public.The function start at line 393 and ends at 394. 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_wait_for_job_completion_max_interval_cap | def test_wait_for_job_completion_max_interval_cap():"""Test that wait_for_job_completion caps at max_poll_interval."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client:deadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# Return RUNNING for many calls, then SUCCEEDEDdeadline_mock.get_job.side_effect = [MOCK_JOB_RUNNING] * 10 + [MOCK_JOB_SUCCEEDED]# Mock time.sleep to track the intervalssleep_intervals = []def mock_sleep(interval):sleep_intervals.append(interval)with patch("time.sleep", side_effect=mock_sleep):# Mock datetime.now to simulate elapsed timestart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 12, 0, 10)with patch("datetime.datetime") as dt_mock:dt_mock.now.side_effect = [start_time, end_time]result = wait_for_job_completion(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,job_id=MOCK_JOB_ID,max_poll_interval=3,# Small max to test capping)assert isinstance(result, JobCompletionResult)assert result.status == "SUCCEEDED"# Verify intervals cap at max_poll_interval: 0.5, 1.0, 2.0, 3.0, 3.0, ...assert len(sleep_intervals) == 10assert sleep_intervals[0] == pytest.approx(0.5)assert sleep_intervals[1] == pytest.approx(1.0)assert sleep_intervals[2] == pytest.approx(2.0)# All subsequent intervals should be capped at 3.0for i in range(3, 10):assert sleep_intervals[i] == pytest.approx(3.0) | 2 | 26 | 0 | 216 | 5 | 379 | 421 | 379 | ['end_time', 'sleep_intervals', 'deadline_mock', 'start_time', 'result'] | None | {"Assign": 8, "Expr": 2, "For": 1, "With": 3} | 15 | 43 | 15 | ["patch", "MagicMock", "sleep_intervals.append", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "len", "pytest.approx", "pytest.approx", "pytest.approx", "range", "pytest.approx"] | 0 | [] | The function (test_wait_for_job_completion_max_interval_cap) defined within the public class called public.The function start at line 379 and ends at 421. It contains 26 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 15.0 functions, and It has 15.0 functions called inside which are ["patch", "MagicMock", "sleep_intervals.append", "patch", "datetime.datetime", "datetime.datetime", "patch", "wait_for_job_completion", "isinstance", "len", "pytest.approx", "pytest.approx", "pytest.approx", "range", "pytest.approx"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_basic | def test_get_session_logs_basic():"""Test that get_session_logs works correctly with basic parameters."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user:# Mock user and identity store ID to be None (standard credentials path)mock_get_user.return_value = (None, None)# Set up logs client mocklogs_client_mock = MagicMock()logs_client_mock.get_log_events.return_value = MOCK_GET_LOG_EVENTS_RESPONSEmock_get_client.return_value = logs_client_mock# Call the functionresult = get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",limit=100,)# Verify the resultassert isinstance(result, SessionLogResult)assert len(result.events) == 2assert result.events[0].message == "Log message 1"assert result.events[1].message == "Log message 2"assert result.next_token == "next-token"assert result.log_group == f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}"assert result.log_stream == "session-test-session"assert result.count == 2# Verify the logs client was called with correct parameterslogs_client_mock.get_log_events.assert_called_once_with(logGroupName=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",logStreamName="session-test-session",limit=100,startFromHead=False,) | 1 | 28 | 0 | 154 | 2 | 424 | 463 | 424 | ['result', 'logs_client_mock'] | None | {"Assign": 5, "Expr": 2, "With": 1} | 7 | 40 | 7 | ["patch", "patch", "MagicMock", "get_session_logs", "isinstance", "len", "logs_client_mock.get_log_events.assert_called_once_with"] | 0 | [] | The function (test_get_session_logs_basic) defined within the public class called public.The function start at line 424 and ends at 463. It contains 28 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 ["patch", "patch", "MagicMock", "get_session_logs", "isinstance", "len", "logs_client_mock.get_log_events.assert_called_once_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_with_datetime_params | def test_get_session_logs_with_datetime_params():"""Test that get_session_logs works correctly with datetime parameters."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user:# Mock user and identity store ID to be None (standard credentials path)mock_get_user.return_value = (None, None)# Set up logs client mocklogs_client_mock = MagicMock()logs_client_mock.get_log_events.return_value = MOCK_GET_LOG_EVENTS_RESPONSEmock_get_client.return_value = logs_client_mock# Create datetime objects for start and end timesstart_time = datetime.datetime(2023, 1, 1, 12, 0, 0)end_time = datetime.datetime(2023, 1, 1, 13, 0, 0)# Call the function with datetime parametersresult = get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",limit=100,start_time=start_time,end_time=end_time,)# Verify the resultassert isinstance(result, SessionLogResult)assert len(result.events) == 2# Verify the logs client was called with correct parameterslogs_client_mock.get_log_events.assert_called_once_with(logGroupName=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",logStreamName="session-test-session",limit=100,startFromHead=False,startTime=int(start_time.timestamp() * 1000),endTime=int(end_time.timestamp() * 1000),) | 1 | 28 | 0 | 177 | 4 | 466 | 507 | 466 | ['start_time', 'result', 'end_time', 'logs_client_mock'] | None | {"Assign": 7, "Expr": 2, "With": 1} | 13 | 42 | 13 | ["patch", "patch", "MagicMock", "datetime.datetime", "datetime.datetime", "get_session_logs", "isinstance", "len", "logs_client_mock.get_log_events.assert_called_once_with", "int", "start_time.timestamp", "int", "end_time.timestamp"] | 0 | [] | The function (test_get_session_logs_with_datetime_params) defined within the public class called public.The function start at line 466 and ends at 507. It contains 28 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 ["patch", "patch", "MagicMock", "datetime.datetime", "datetime.datetime", "get_session_logs", "isinstance", "len", "logs_client_mock.get_log_events.assert_called_once_with", "int", "start_time.timestamp", "int", "end_time.timestamp"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_with_monitor_credentials | def test_get_session_logs_with_monitor_credentials():"""Test that get_session_logs works correctly with Deadline Cloud monitor credentials."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user, patch("deadline.client.api._job_monitoring.get_queue_user_boto3_session") as mock_get_session:# Mock user and identity store ID to simulate monitor credentialsmock_get_user.return_value = ("user-123", "identity-store-456")# Set up queue session mockqueue_session_mock = MagicMock()logs_client_mock = MagicMock()logs_client_mock.get_log_events.return_value = MOCK_GET_LOG_EVENTS_RESPONSEqueue_session_mock.client.return_value = logs_client_mockmock_get_session.return_value = queue_session_mock# Set up deadline client mockdeadline_mock = MagicMock()mock_get_client.return_value = deadline_mock# Call the functionresult = get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",limit=100,)# Verify the resultassert isinstance(result, SessionLogResult)assert len(result.events) == 2# Verify the queue session was created with correct parametersmock_get_session.assert_called_once_with(deadline=deadline_mock,config=None,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,)# Verify the logs client was created from the queue sessionqueue_session_mock.client.assert_called_once_with("logs")# Verify the logs client was called with correct parameterslogs_client_mock.get_log_events.assert_called_once_with(logGroupName=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",logStreamName="session-test-session",limit=100,startFromHead=False,) | 1 | 35 | 0 | 165 | 4 | 510 | 562 | 510 | ['result', 'queue_session_mock', 'deadline_mock', 'logs_client_mock'] | None | {"Assign": 9, "Expr": 4, "With": 1} | 12 | 53 | 12 | ["patch", "patch", "patch", "MagicMock", "MagicMock", "MagicMock", "get_session_logs", "isinstance", "len", "mock_get_session.assert_called_once_with", "queue_session_mock.client.assert_called_once_with", "logs_client_mock.get_log_events.assert_called_once_with"] | 0 | [] | The function (test_get_session_logs_with_monitor_credentials) defined within the public class called public.The function start at line 510 and ends at 562. It contains 35 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 ["patch", "patch", "patch", "MagicMock", "MagicMock", "MagicMock", "get_session_logs", "isinstance", "len", "mock_get_session.assert_called_once_with", "queue_session_mock.client.assert_called_once_with", "logs_client_mock.get_log_events.assert_called_once_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_with_next_token | def test_get_session_logs_with_next_token():"""Test that get_session_logs works correctly with pagination token."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user:# Mock user and identity store ID to be None (standard credentials path)mock_get_user.return_value = (None, None)# Set up logs client mocklogs_client_mock = MagicMock()logs_client_mock.get_log_events.return_value = MOCK_GET_LOG_EVENTS_RESPONSEmock_get_client.return_value = logs_client_mock# Call the function with next_tokenresult = get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",limit=100,next_token="previous-token",)# Verify the resultassert isinstance(result, SessionLogResult)assert result.next_token == "next-token"# Verify the logs client was called with correct parameterslogs_client_mock.get_log_events.assert_called_once_with(logGroupName=f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}",logStreamName="session-test-session",limit=100,startFromHead=False,nextToken="previous-token",) | 1 | 24 | 0 | 112 | 2 | 565 | 600 | 565 | ['result', 'logs_client_mock'] | None | {"Assign": 5, "Expr": 2, "With": 1} | 6 | 36 | 6 | ["patch", "patch", "MagicMock", "get_session_logs", "isinstance", "logs_client_mock.get_log_events.assert_called_once_with"] | 0 | [] | The function (test_get_session_logs_with_next_token) defined within the public class called public.The function start at line 565 and ends at 600. It contains 24 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 ["patch", "patch", "MagicMock", "get_session_logs", "isinstance", "logs_client_mock.get_log_events.assert_called_once_with"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_resource_not_found | def test_get_session_logs_resource_not_found():"""Test that get_session_logs handles ResourceNotFoundException correctly."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user:# Mock user and identity store ID to be None (standard credentials path)mock_get_user.return_value = (None, None)# Set up logs client mock with ResourceNotFoundExceptionlogs_client_mock = MagicMock()logs_client_mock.exceptions.ResourceNotFoundException = type("ResourceNotFoundException", (Exception,), {})logs_client_mock.get_log_events.side_effect = (logs_client_mock.exceptions.ResourceNotFoundException())mock_get_client.return_value = logs_client_mock# Call the functionresult = get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",limit=100,)# Verify the result is empty but validassert isinstance(result, SessionLogResult)assert len(result.events) == 0assert result.next_token is Noneassert result.log_group == f"/aws/deadline/{MOCK_FARM_ID}/{MOCK_QUEUE_ID}"assert result.log_stream == "session-test-session"assert result.count == 0 | 1 | 25 | 0 | 134 | 2 | 603 | 637 | 603 | ['result', 'logs_client_mock'] | None | {"Assign": 6, "Expr": 1, "With": 1} | 8 | 35 | 8 | ["patch", "patch", "MagicMock", "type", "logs_client_mock.exceptions.ResourceNotFoundException", "get_session_logs", "isinstance", "len"] | 0 | [] | The function (test_get_session_logs_resource_not_found) defined within the public class called public.The function start at line 603 and ends at 637. It contains 25 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", "patch", "MagicMock", "type", "logs_client_mock.exceptions.ResourceNotFoundException", "get_session_logs", "isinstance", "len"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_get_session_logs_invalid_datetime | def test_get_session_logs_invalid_datetime():"""Test that get_session_logs handles invalid datetime objects correctly."""with patch("deadline.client.api._job_monitoring.get_boto3_client") as mock_get_client, patch("deadline.client.api._job_monitoring.get_user_and_identity_store_id") as mock_get_user:# Mock user and identity store ID to be None (standard credentials path)mock_get_user.return_value = (None, None)# Set up logs client mocklogs_client_mock = MagicMock()mock_get_client.return_value = logs_client_mock# Create an invalid datetime object (None with timestamp attribute that raises)invalid_datetime = MagicMock()invalid_datetime.timestamp.side_effect = AttributeError("'NoneType' object has no attribute 'timestamp'")# Call the function with invalid datetime and verify it raises an errortry:get_session_logs(farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,session_id="session-test-session",start_time=invalid_datetime,)assert False, "Expected DeadlineOperationError was not raised"except DeadlineOperationError as e:assert "Invalid start time" in str(e) | 2 | 21 | 0 | 91 | 2 | 640 | 670 | 640 | ['invalid_datetime', 'logs_client_mock'] | None | {"Assign": 5, "Expr": 2, "Try": 1, "With": 1} | 7 | 31 | 7 | ["patch", "patch", "MagicMock", "MagicMock", "AttributeError", "get_session_logs", "str"] | 0 | [] | The function (test_get_session_logs_invalid_datetime) defined within the public class called public.The function start at line 640 and ends at 670. It contains 21 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 7.0 functions, and It has 7.0 functions called inside which are ["patch", "patch", "MagicMock", "MagicMock", "AttributeError", "get_session_logs", "str"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | mock_boto3_session | def mock_boto3_session():"""Create a mock boto3 session for tests."""session = MagicMock()session.client.return_value = MagicMock()return session | 1 | 4 | 0 | 21 | 1 | 24 | 28 | 24 | ['session'] | Returns | {"Assign": 2, "Expr": 1, "Return": 1} | 2 | 5 | 2 | ["MagicMock", "MagicMock"] | 0 | [] | The function (mock_boto3_session) defined within the public class called public.The function start at line 24 and ends at 28. 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 2.0 functions, and It has 2.0 functions called inside which are ["MagicMock", "MagicMock"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_list_jobs_by_filter_with_incorrect_filter_expression | def test_list_jobs_by_filter_with_incorrect_filter_expression(mock_boto3_session):"""Test parameter validation of the timestamp"""# Mock SearchJobs to assert it wasn't calledmock_boto3_session.client().search_jobs.return_value = {}# Test when both timestamp and look_back_duration are missingwith pytest.raises(ValueError) as excinfo:_list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,filter_expression=None,# type: ignore)assert "The provided filter expression must be a dict" in str(excinfo.value)# Test when both timestamp and look_back_duration are providedwith pytest.raises(ValueError) as excinfo:_list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,# Missing the "operator"filter_expression={"filters": []},)assert "The provided filter expression must contain 'filters' and 'operator'" in str(excinfo.value) | 1 | 20 | 1 | 99 | 0 | 31 | 57 | 31 | mock_boto3_session | [] | None | {"Assign": 1, "Expr": 3, "With": 2} | 7 | 27 | 7 | ["mock_boto3_session.client", "pytest.raises", "_list_jobs_by_filter_expression", "str", "pytest.raises", "_list_jobs_by_filter_expression", "str"] | 0 | [] | The function (test_list_jobs_by_filter_with_incorrect_filter_expression) defined within the public class called public.The function start at line 31 and ends at 57. It contains 20 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 ["mock_boto3_session.client", "pytest.raises", "_list_jobs_by_filter_expression", "str", "pytest.raises", "_list_jobs_by_filter_expression", "str"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_list_jobs_recent_jobs_timestamp | def test_list_jobs_recent_jobs_timestamp(fresh_deadline_config,mock_boto3_session,use_look_back,timestamp_field_name,job_count,expected_call_count,):"""Test cases calling with with a matrix of variations"""updated_at_min = datetime(2025, 1, 1, tzinfo=timezone.utc)updated_at_max = datetime(2025, 1, 1, 23, tzinfo=timezone.utc)jobs = create_fake_job_list(job_count, updated_at_min, updated_at_max)# Create the fake deadline:SearchJobs API, wrapped in a mock we can inspectmock_search_jobs = MagicMock(wraps=mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, jobs))mock_boto3_session.client().search_jobs = mock_search_jobs# The function under testresult = _list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,filter_expression={"filters": [{"dateTimeFilter": {"name": timestamp_field_name.replace("At", "_at").upper(),"dateTime": updated_at_min,"operator": "GREATER_THAN_EQUAL_TO",}}],"operator": "AND",},)assert mock_search_jobs.call_count == expected_call_countassert sorted(result, key=lambda v: v[timestamp_field_name]) == sorted(jobs, key=lambda v: v[timestamp_field_name]) | 1 | 34 | 6 | 181 | 5 | 80 | 119 | 80 | fresh_deadline_config,mock_boto3_session,use_look_back,timestamp_field_name,job_count,expected_call_count | ['updated_at_max', 'mock_search_jobs', 'updated_at_min', 'result', 'jobs'] | None | {"Assign": 6, "Expr": 1} | 14 | 40 | 14 | ["datetime", "datetime", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "_list_jobs_by_filter_expression", "upper", "timestamp_field_name.replace", "sorted", "sorted", "pytest.mark.parametrize", "pytest.mark.parametrize", "pytest.mark.parametrize"] | 0 | [] | The function (test_list_jobs_recent_jobs_timestamp) defined within the public class called public.The function start at line 80 and ends at 119. It contains 34 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [80.0] and does not return any value. It declares 14.0 functions, and It has 14.0 functions called inside which are ["datetime", "datetime", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "_list_jobs_by_filter_expression", "upper", "timestamp_field_name.replace", "sorted", "sorted", "pytest.mark.parametrize", "pytest.mark.parametrize", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_list_jobs_recent_jobs_timestamp_partial_jobs_return | def test_list_jobs_recent_jobs_timestamp_partial_jobs_return(fresh_deadline_config, mock_boto3_session):"""Test cases calling with timestamp parameter, where it's somewhere in the middle of the timestamp range"""updated_at_min = datetime(2025, 1, 1, tzinfo=timezone.utc)updated_at_max = datetime(2025, 1, 1, 23, tzinfo=timezone.utc)updated_at_micros_range = int((updated_at_max - updated_at_min).total_seconds() * 1000000)jobs = create_fake_job_list(1000, updated_at_min, updated_at_max)# Create the fake deadline:SearchJobs API, wrapped in a mock we can inspectmock_search_jobs = MagicMock(wraps=mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, jobs))mock_boto3_session.client().search_jobs = mock_search_jobs# Run a few random casesfor _ in range(10):mock_search_jobs.reset_mock()# Create a random value for the filterrandom_micros = randrange(0, updated_at_micros_range) if updated_at_micros_range > 0 else 0updated_at_filter = updated_at_min + timedelta(microseconds=random_micros)# The function under testresult = _list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,filter_expression={"filters": [{"dateTimeFilter": {"name": "ENDED_AT","dateTime": updated_at_filter,"operator": "GREATER_THAN_EQUAL_TO",}}],"operator": "AND",},)# The resulting set of jobs should matchfiltered_jobs = (job for job in jobs if job["endedAt"] >= updated_at_filter)assert sorted(result, key=lambda v: v["createdAt"]) == sorted(filtered_jobs, key=lambda v: v["createdAt"]) | 5 | 34 | 2 | 224 | 9 | 122 | 165 | 122 | fresh_deadline_config,mock_boto3_session | ['updated_at_max', 'random_micros', 'filtered_jobs', 'updated_at_micros_range', 'updated_at_filter', 'mock_search_jobs', 'updated_at_min', 'result', 'jobs'] | None | {"Assign": 10, "Expr": 2, "For": 1} | 15 | 44 | 15 | ["datetime", "datetime", "int", "total_seconds", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "range", "mock_search_jobs.reset_mock", "randrange", "timedelta", "_list_jobs_by_filter_expression", "sorted", "sorted"] | 0 | [] | The function (test_list_jobs_recent_jobs_timestamp_partial_jobs_return) defined within the public class called public.The function start at line 122 and ends at 165. It contains 34 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [122.0] and does not return any value. It declares 15.0 functions, and It has 15.0 functions called inside which are ["datetime", "datetime", "int", "total_seconds", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "range", "mock_search_jobs.reset_mock", "randrange", "timedelta", "_list_jobs_by_filter_expression", "sorted", "sorted"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_list_jobs_recent_edge_case_many_equal_timestamps | def test_list_jobs_recent_edge_case_many_equal_timestamps(fresh_deadline_config, mock_boto3_session):"""Test edge case when there are > 100 exactly equal timestamps."""updated_at_min = datetime(2025, 1, 1, tzinfo=timezone.utc)updated_at_max = datetime(2025, 1, 1, 23, tzinfo=timezone.utc)# Repeat the midpoint a bunch of timesupdated_at_repeated = updated_at_min + 0.5 * (updated_at_max - updated_at_min)jobs = create_fake_job_list(100, updated_at_min, updated_at_max)jobs.extend(create_fake_job_list(101, updated_at_repeated, updated_at_repeated))# Sorted by timestamp, the jobs dataset has ~50 jobs with random timestamps, 101 jobs with repeated timestamp,# and then ~50 more jobs with random timestamps again. The first SearchJobs call returns about half of its# jobs with repeated timestamps, and then the second call returns the first 100 jobs with repeated timestamp and# so misses the 101st.# Create the fake deadline:SearchJobs API, wrapped in a mock we can inspectmock_search_jobs = MagicMock(wraps=mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, jobs))mock_boto3_session.client().search_jobs = mock_search_jobswith pytest.raises(JobFetchFailure) as excinfo:_list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,filter_expression={"filters": [{"dateTimeFilter": {"name": "UPDATED_AT","dateTime": updated_at_min,"operator": "GREATER_THAN_EQUAL_TO",}}],"operator": "AND",},)assert "more then 100 jobs have the exact same timestamp value" in str(excinfo.value)assert mock_search_jobs.call_count == 2# The way the algorithm and test data set are structured, the first call will filter from the provided parameter# timestamp, and the second call will filter from the repeated timestampassert len(mock_search_jobs.call_args_list[0].kwargs["filterExpressions"]["filters"]) == 1assert len(mock_search_jobs.call_args_list[1].kwargs["filterExpressions"]["filters"]) == 2assert (mock_search_jobs.call_args_list[1].kwargs["filterExpressions"]["filters"][1]["dateTimeFilter"]["dateTime"]== updated_at_repeated) | 1 | 38 | 2 | 242 | 5 | 168 | 219 | 168 | fresh_deadline_config,mock_boto3_session | ['updated_at_max', 'updated_at_repeated', 'mock_search_jobs', 'updated_at_min', 'jobs'] | None | {"Assign": 6, "Expr": 3, "With": 1} | 13 | 52 | 13 | ["datetime", "datetime", "create_fake_job_list", "jobs.extend", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "pytest.raises", "_list_jobs_by_filter_expression", "str", "len", "len"] | 0 | [] | The function (test_list_jobs_recent_edge_case_many_equal_timestamps) defined within the public class called public.The function start at line 168 and ends at 219. It contains 38 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [168.0] and does not return any value. It declares 13.0 functions, and It has 13.0 functions called inside which are ["datetime", "datetime", "create_fake_job_list", "jobs.extend", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "pytest.raises", "_list_jobs_by_filter_expression", "str", "len", "len"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_list_jobs_by_filter_expression | def test_list_jobs_by_filter_expression(fresh_deadline_config,mock_boto3_session,job_count,):"""Test cases calling with with a matrix of variations"""test_status_values = ["READY", "ASSIGNED", "STARTING"]jobs = sorted(create_fake_job_list(job_count), key=lambda job: job["jobId"])# Create the fake deadline:SearchJobs API, wrapped in a mock we can inspectmock_search_jobs = MagicMock(wraps=mock_search_jobs_for_set(MOCK_FARM_ID, MOCK_QUEUE_ID, jobs))mock_boto3_session.client().search_jobs = mock_search_jobs# The function under testresult = _list_jobs_by_filter_expression(boto3_session=mock_boto3_session,farm_id=MOCK_FARM_ID,queue_id=MOCK_QUEUE_ID,filter_expression={"filters": [{"stringFilter": {"name": "TASK_RUN_STATUS","operator": "EQUAL","value": status_value,},}for status_value in test_status_values],"operator": "OR",},)# The result should be the full set of jobs matching the filter criteria. The order is arbitrary, so we sort to compare.assert sorted(result, key=lambda job: job["jobId"]) == [job for job in jobs if job["taskRunStatus"] in test_status_values] | 4 | 30 | 3 | 147 | 4 | 223 | 260 | 223 | fresh_deadline_config,mock_boto3_session,job_count | ['mock_search_jobs', 'result', 'test_status_values', 'jobs'] | None | {"Assign": 5, "Expr": 1} | 8 | 38 | 8 | ["sorted", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "_list_jobs_by_filter_expression", "sorted", "pytest.mark.parametrize"] | 0 | [] | The function (test_list_jobs_by_filter_expression) defined within the public class called public.The function start at line 223 and ends at 260. It contains 30 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [223.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["sorted", "create_fake_job_list", "MagicMock", "mock_search_jobs_for_set", "mock_boto3_session.client", "_list_jobs_by_filter_expression", "sorted", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | mock_boto3_client | def mock_boto3_client():"""Mock the boto3 client."""with mock.patch("deadline.client.api._session.get_boto3_client") as mock_get_client:mock_client = mock.MagicMock()mock_get_client.return_value = mock_clientyield mock_client | 1 | 5 | 0 | 29 | 1 | 15 | 20 | 15 | ['mock_client'] | None | {"Assign": 2, "Expr": 2, "With": 1} | 2 | 6 | 2 | ["mock.patch", "mock.MagicMock"] | 0 | [] | The function (mock_boto3_client) defined within the public class called public.The function start at line 15 and ends at 20. 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 ["mock.patch", "mock.MagicMock"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_assume_queue_role_for_user | def test_assume_queue_role_for_user(mock_boto3_client):"""Test assuming user role for a queue."""# Setupexpiration = datetime.datetime(2025, 4, 8, 20, 0, 46)mock_boto3_client.assume_queue_role_for_user.return_value = {"Credentials": {"AccessKeyId": "ASIAEXAMPLE","SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","SessionToken": "AQoDYXdzEJr...<remainder of session token>","Expiration": expiration,}}# Executeresult = queue_credentials.assume_queue_role_for_user(farmId="farm-1234567890abcdefg", queueId="q-12345abcdef")# Verifymock_boto3_client.assume_queue_role_for_user.assert_called_once_with(farmId="farm-1234567890abcdefg", queueId="q-12345abcdef")assert result["Credentials"]["AccessKeyId"] == "ASIAEXAMPLE"assert result["Credentials"]["SecretAccessKey"] == "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"assert result["Credentials"]["SessionToken"] == "AQoDYXdzEJr...<remainder of session token>"assert result["Credentials"]["Expiration"] == expiration | 1 | 20 | 1 | 120 | 2 | 23 | 48 | 23 | mock_boto3_client | ['result', 'expiration'] | None | {"Assign": 3, "Expr": 2} | 3 | 26 | 3 | ["datetime.datetime", "queue_credentials.assume_queue_role_for_user", "mock_boto3_client.assume_queue_role_for_user.assert_called_once_with"] | 0 | [] | The function (test_assume_queue_role_for_user) defined within the public class called public.The function start at line 23 and ends at 48. It contains 20 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 ["datetime.datetime", "queue_credentials.assume_queue_role_for_user", "mock_boto3_client.assume_queue_role_for_user.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_assume_queue_role_for_read | def test_assume_queue_role_for_read(mock_boto3_client):"""Test assuming read role for a queue."""# Setupexpiration = datetime.datetime(2025, 4, 8, 20, 0, 46)mock_boto3_client.assume_queue_role_for_read.return_value = {"Credentials": {"AccessKeyId": "ASIAEXAMPLE","SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","SessionToken": "AQoDYXdzEJr...<remainder of session token>","Expiration": expiration,}}# Executeresult = queue_credentials.assume_queue_role_for_read(farmId="farm-1234567890abcdefg", queueId="q-12345abcdef")# Verifymock_boto3_client.assume_queue_role_for_read.assert_called_once_with(farmId="farm-1234567890abcdefg", queueId="q-12345abcdef")assert result["Credentials"]["AccessKeyId"] == "ASIAEXAMPLE"assert result["Credentials"]["SecretAccessKey"] == "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"assert result["Credentials"]["SessionToken"] == "AQoDYXdzEJr...<remainder of session token>"assert result["Credentials"]["Expiration"] == expiration | 1 | 20 | 1 | 120 | 2 | 51 | 76 | 51 | mock_boto3_client | ['result', 'expiration'] | None | {"Assign": 3, "Expr": 2} | 3 | 26 | 3 | ["datetime.datetime", "queue_credentials.assume_queue_role_for_read", "mock_boto3_client.assume_queue_role_for_read.assert_called_once_with"] | 0 | [] | The function (test_assume_queue_role_for_read) defined within the public class called public.The function start at line 51 and ends at 76. It contains 20 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 ["datetime.datetime", "queue_credentials.assume_queue_role_for_read", "mock_boto3_client.assume_queue_role_for_read.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_assume_queue_role_client_error | def test_assume_queue_role_client_error(mock_boto3_client):"""Test error handling when assuming role fails."""# Setupfrom botocore.exceptions import ClientErrormock_boto3_client.assume_queue_role_for_user.side_effect = ClientError({"Error": {"Code": "AccessDenied", "Message": "Access denied"}},"AssumeQueueRoleForUser",)# Execute and verifywith pytest.raises(ClientError) as excinfo:queue_credentials.assume_queue_role_for_user(farmId="farm-1234567890abcdefg", queueId="q-12345abcdef")assert "AccessDenied" in str(excinfo.value) | 1 | 11 | 1 | 68 | 0 | 79 | 95 | 79 | mock_boto3_client | [] | None | {"Assign": 1, "Expr": 2, "With": 1} | 4 | 17 | 4 | ["ClientError", "pytest.raises", "queue_credentials.assume_queue_role_for_user", "str"] | 0 | [] | The function (test_assume_queue_role_client_error) defined within the public class called public.The function start at line 79 and ends at 95. 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 4.0 functions, and It has 4.0 functions called inside which are ["ClientError", "pytest.raises", "queue_credentials.assume_queue_role_for_user", "str"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_debug_logging_on | def test_cli_debug_logging_on(fresh_deadline_config):"""Confirm that --log-level DEBUG turns on debug logging."""# The CliRunner environment already has the logger configured,# so we instead run it as a subprocess to match the actual# environment.output = subprocess.check_output(args=[sys.executable, "-m", "deadline", "--log-level", "DEBUG", "config", "--help"],stderr=subprocess.STDOUT,text=True,)assert "Debug logging is on" in output | 1 | 7 | 1 | 47 | 1 | 23 | 36 | 23 | fresh_deadline_config | ['output'] | None | {"Assign": 1, "Expr": 1} | 1 | 14 | 1 | ["subprocess.check_output"] | 0 | [] | The function (test_cli_debug_logging_on) defined within the public class called public.The function start at line 23 and ends at 36. 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 declare 1.0 function, and It has 1.0 function called inside which is ["subprocess.check_output"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_redirect_output | def test_cli_redirect_output(fresh_deadline_config, tmp_path):"""Confirm that --redirect-output FILENAME sends stdout/stderr to a file."""# The CliRunner environment already has the logger configured,# so we instead run it as a subprocess to match the actual# environment.out_file = tmp_path / "out.txt"output = subprocess.check_output(args=[sys.executable,"-m","deadline","--redirect-output",str(out_file),"config","--help",],stderr=subprocess.STDOUT,text=True,)# No output should be printed to stdout or stderr.assert output == ""# The help information should be in the provided output file.with open(out_file, encoding="utf-8") as fh:file_output = fh.read()assert file_output.startswith("Usage: ")assert "Manage Deadline's workstation configuration." in file_output | 1 | 20 | 2 | 88 | 3 | 39 | 68 | 39 | fresh_deadline_config,tmp_path | ['output', 'file_output', 'out_file'] | None | {"Assign": 3, "Expr": 1, "With": 1} | 5 | 30 | 5 | ["subprocess.check_output", "str", "open", "fh.read", "file_output.startswith"] | 0 | [] | The function (test_cli_redirect_output) defined within the public class called public.The function start at line 39 and ends at 68. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [39.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["subprocess.check_output", "str", "open", "fh.read", "file_output.startswith"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_redirect_output_with_mode | def test_cli_redirect_output_with_mode(fresh_deadline_config, tmp_path, redirect_mode):"""Confirm that --redirect-output FILENAME sends stdout/stderr to a file,and --redirect-mode controls appending vs replacing."""out_file = tmp_path / "out.txt"with open(out_file, "w", encoding="utf-8") as fh:fh.write("Initial contents\n")# The CliRunner environment already has the logger configured,# so we instead run it as a subprocess to match the actual# environment.output = subprocess.check_output(args=[sys.executable,"-m","deadline","--redirect-output",str(out_file),"--redirect-mode",redirect_mode,"config","--help",],stderr=subprocess.STDOUT,text=True,)# No output should be printed to stdout or stderr.assert output == ""# The help information should be in the provided output file.with open(out_file, encoding="utf-8") as fh:file_output = fh.read()if redirect_mode == "append":# Should be appended to the starting file contents.assert file_output.startswith("Initial contents\nUsage: "), file_outputelse:# The starting file contents should be replacedassert file_output.startswith("Usage: "), file_outputassert "Manage Deadline's workstation configuration." in file_output, file_output | 2 | 27 | 3 | 134 | 3 | 72 | 113 | 72 | fresh_deadline_config,tmp_path,redirect_mode | ['output', 'file_output', 'out_file'] | None | {"Assign": 3, "Expr": 2, "If": 1, "With": 2} | 9 | 42 | 9 | ["open", "fh.write", "subprocess.check_output", "str", "open", "fh.read", "file_output.startswith", "file_output.startswith", "pytest.mark.parametrize"] | 0 | [] | The function (test_cli_redirect_output_with_mode) defined within the public class called public.The function start at line 72 and ends at 113. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [72.0] and does not return any value. It declares 9.0 functions, and It has 9.0 functions called inside which are ["open", "fh.write", "subprocess.check_output", "str", "open", "fh.read", "file_output.startswith", "file_output.startswith", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_unfamiliar_exception | def test_cli_unfamiliar_exception(fresh_deadline_config):"""Test that unfamiliar exceptions get the extra context"""# Change the `login` function so it just raises an exceptionwith patch.object(api._session, "get_boto3_session"), patch.object(api, "login") as login_mock:login_mock.side_effect = Exception("An unexpected exception")runner = CliRunner()result = runner.invoke(main, ["auth", "login"])assert "encountered the following exception" in result.outputassert "An unexpected exception" in result.outputassert result.exit_code == 1 | 1 | 8 | 1 | 74 | 2 | 116 | 129 | 116 | fresh_deadline_config | ['runner', 'result'] | None | {"Assign": 3, "Expr": 1, "With": 1} | 5 | 14 | 5 | ["patch.object", "patch.object", "Exception", "CliRunner", "runner.invoke"] | 0 | [] | The function (test_cli_unfamiliar_exception) defined within the public class called public.The function start at line 116 and ends at 129. 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 5.0 functions, and It has 5.0 functions called inside which are ["patch.object", "patch.object", "Exception", "CliRunner", "runner.invoke"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_group_without_command | def test_cli_group_without_command(fresh_deadline_config, cli_group):"""Test that each group prints the usage screen if no command is provided"""runner = CliRunner()result = runner.invoke(main, [cli_group])assert result.output.startswith("Usage:") | 1 | 4 | 2 | 34 | 2 | 133 | 140 | 133 | fresh_deadline_config,cli_group | ['runner', 'result'] | None | {"Assign": 2, "Expr": 1} | 4 | 8 | 4 | ["CliRunner", "runner.invoke", "result.output.startswith", "pytest.mark.parametrize"] | 0 | [] | The function (test_cli_group_without_command) defined within the public class called public.The function start at line 133 and ends at 140. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [133.0] and does not return any value. It declares 4.0 functions, and It has 4.0 functions called inside which are ["CliRunner", "runner.invoke", "result.output.startswith", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_object_repr | def test_cli_object_repr(obj, expected):"""Test that the CLI object represntation is expected."""assert _cli_object_repr(obj) == expected | 1 | 2 | 2 | 15 | 0 | 164 | 168 | 164 | obj,expected | [] | None | {"Expr": 1} | 8 | 5 | 8 | ["_cli_object_repr", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param", "pytest.param", "pytest.param", "pytest.param"] | 0 | [] | The function (test_cli_object_repr) defined within the public class called public.The function start at line 164 and ends at 168. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [164.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["_cli_object_repr", "pytest.mark.parametrize", "pytest.param", "pytest.param", "pytest.param", "pytest.param", "pytest.param", "pytest.param"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_all_cli_commands_use_context_tracking_command._get_all_click_commands | def _get_all_click_commands(cmd: click.Command,found_cmds: List[click.Command],) -> List[click.Command]:"""Gets all leaf commands under a given command"""if isinstance(cmd, click.Group):for subcmd in cmd.commands.values():_get_all_click_commands(subcmd, found_cmds)else:found_cmds.append(cmd)return found_cmds | 3 | 10 | 2 | 64 | 0 | 176 | 186 | 176 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_all_cli_commands_use_context_tracking_command._get_all_click_commands) defined within the public class called public.The function start at line 176 and ends at 186. It contains 10 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [176.0] and does not return any value.. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_all_cli_commands_use_context_tracking_command | def test_all_cli_commands_use_context_tracking_command():"""Retrieves all click commands and verifies they all use the ContextTrackingCommand subclass"""def _get_all_click_commands(cmd: click.Command,found_cmds: List[click.Command],) -> List[click.Command]:"""Gets all leaf commands under a given command"""if isinstance(cmd, click.Group):for subcmd in cmd.commands.values():_get_all_click_commands(subcmd, found_cmds)else:found_cmds.append(cmd)return found_cmdsall_commands = _get_all_click_commands(cmd=main, found_cmds=[])assert all([isinstance(cmd, ContextTrackingCommand) for cmd in all_commands]) | 2 | 4 | 0 | 36 | 1 | 171 | 189 | 171 | ['all_commands'] | Returns | {"Assign": 1, "Expr": 4, "For": 1, "If": 1, "Return": 1} | 7 | 19 | 7 | ["isinstance", "cmd.commands.values", "_get_all_click_commands", "found_cmds.append", "_get_all_click_commands", "all", "isinstance"] | 0 | [] | The function (test_all_cli_commands_use_context_tracking_command) defined within the public class called public.The function start at line 171 and ends at 189. It contains 4 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters, and this function return a value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["isinstance", "cmd.commands.values", "_get_all_click_commands", "found_cmds.append", "_get_all_click_commands", "all", "isinstance"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_context_tracking_command_sets_boto_user_agent_extra.test_main | def test_main():pass | 1 | 2 | 0 | 5 | 0 | 198 | 199 | 198 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_context_tracking_command_sets_boto_user_agent_extra.test_main) defined within the public class called public.The function start at line 198 and ends at 199. 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_context_tracking_command_sets_boto_user_agent_extra.test_subcmd | def test_subcmd():pass | 1 | 2 | 0 | 5 | 0 | 202 | 203 | 202 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_context_tracking_command_sets_boto_user_agent_extra.test_subcmd) defined within the public class called public.The function start at line 202 and ends at 203. 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_context_tracking_command_sets_boto_user_agent_extra.test_command | def test_command():pass | 1 | 2 | 0 | 5 | 0 | 206 | 207 | 206 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_context_tracking_command_sets_boto_user_agent_extra.test_command) defined within the public class called public.The function start at line 206 and ends at 207. 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_context_tracking_command_sets_boto_user_agent_extra | def test_context_tracking_command_sets_boto_user_agent_extra():"""Verifies that the ContextTrackingCommand sets the user_agent_extra in boto clients"""@click.group(cls=ContextTrackingGroup, name="main")def test_main():pass@test_main.group(name="subcommand")def test_subcmd():pass@test_subcmd.command(name="command")def test_command():passCliRunner().invoke(test_main, args=["subcommand", "command"])config = get_default_client_config()assert "cli-command/main.subcommand.command" in config.user_agent_extra | 1 | 10 | 0 | 69 | 1 | 192 | 213 | 192 | ['config'] | None | {"Assign": 1, "Expr": 2} | 6 | 22 | 6 | ["click.group", "test_main.group", "test_subcmd.command", "invoke", "CliRunner", "get_default_client_config"] | 0 | [] | The function (test_context_tracking_command_sets_boto_user_agent_extra) defined within the public class called public.The function start at line 192 and ends at 213. 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 6.0 functions, and It has 6.0 functions called inside which are ["click.group", "test_main.group", "test_subcmd.command", "invoke", "CliRunner", "get_default_client_config"]. | |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_attachment_existence | def test_cli_attachment_existence(fresh_deadline_config):"""Confirm that the subcommand group is availble for environment with no JOB_ATTACHMENT_CLI"""assert not os.environ.get("JOB_ATTACHMENT_CLI")runner = CliRunner()response = runner.invoke(main, ["attachment"])assert "Usage: main attachment" in response.output | 1 | 5 | 1 | 39 | 2 | 14 | 24 | 14 | fresh_deadline_config | ['runner', 'response'] | None | {"Assign": 2, "Expr": 1} | 3 | 11 | 3 | ["os.environ.get", "CliRunner", "runner.invoke"] | 0 | [] | The function (test_cli_attachment_existence) defined within the public class called public.The function start at line 14 and ends at 24. 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 ["os.environ.get", "CliRunner", "runner.invoke"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_deadline_cloud_monitor_login_and_logout | def test_cli_deadline_cloud_monitor_login_and_logout(fresh_deadline_config):"""Confirm that the CLI login/logout command invokes Deadline Cloud monitor as expected"""scoped_config = {"credential_process": "/bin/DeadlineCloudMonitor get-credentials --profile sandbox-us-west-2","monitor_id": "monitor-1g9neezauta8ease","region": "us-west-2",}profile_name = "sandbox-us-west-2"config.set_setting("deadline-cloud-monitor.path", "/bin/DeadlineCloudMonitor")config.set_setting("defaults.aws_profile_name", profile_name)with patch.object(api._session, "get_boto3_session") as session_mock, patch.object(api._session._get_boto3_session_for_profile, "cache_clear") as mock_profile_session_cache_clear, patch.object(api._session._get_queue_user_boto3_session, "cache_clear") as mock_queue_session_cache_clear, patch.object(api, "get_boto3_session", new=session_mock), patch.object(subprocess, "Popen") as popen_mock, patch.object(subprocess, "check_output") as check_output_mock:# The profile namesession_mock().profile_name = profile_name# This configuration includes the IdC profilesession_mock()._session.get_scoped_config.return_value = scoped_configsession_mock()._session.full_config = {"profiles": {profile_name: scoped_config}}check_output_mock.return_value = bytes("Successfully logged out", "utf8")runner = CliRunner()result = runner.invoke(main, ["auth", "login"])assert result.exit_code == 0, result.outputif sys.platform.startswith("win"):popen_mock.assert_called_once_with(["/bin/DeadlineCloudMonitor", "login", "--profile", "sandbox-us-west-2"],stdout=subprocess.PIPE,stderr=subprocess.DEVNULL,stdin=subprocess.PIPE,)else:popen_mock.assert_called_once_with(["/bin/DeadlineCloudMonitor", "login", "--profile", "sandbox-us-west-2"],stdout=subprocess.PIPE,stderr=subprocess.DEVNULL,stdin=subprocess.DEVNULL,)assert result.exit_code == 0assert ("Successfully logged in: Deadline Cloud monitor profile: sandbox-us-west-2"in result.output)assert result.exit_code == 0# Now lets logoutrunner = CliRunner()result = runner.invoke(main, ["auth", "logout"])check_output_mock.assert_called_once_with(["/bin/DeadlineCloudMonitor", "logout", "--profile", "sandbox-us-west-2"])assert "Successfully logged out" in result.outputmock_profile_session_cache_clear.assert_called()mock_queue_session_cache_clear.assert_called() | 2 | 53 | 1 | 341 | 4 | 20 | 88 | 20 | fresh_deadline_config | ['result', 'runner', 'profile_name', 'scoped_config'] | None | {"Assign": 10, "Expr": 8, "If": 1, "With": 1} | 22 | 69 | 22 | ["config.set_setting", "config.set_setting", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "session_mock", "session_mock", "session_mock", "bytes", "CliRunner", "runner.invoke", "sys.platform.startswith", "popen_mock.assert_called_once_with", "popen_mock.assert_called_once_with", "CliRunner", "runner.invoke", "check_output_mock.assert_called_once_with", "mock_profile_session_cache_clear.assert_called", "mock_queue_session_cache_clear.assert_called"] | 0 | [] | The function (test_cli_deadline_cloud_monitor_login_and_logout) defined within the public class called public.The function start at line 20 and ends at 88. It contains 53 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 22.0 functions, and It has 22.0 functions called inside which are ["config.set_setting", "config.set_setting", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "patch.object", "session_mock", "session_mock", "session_mock", "bytes", "CliRunner", "runner.invoke", "sys.platform.startswith", "popen_mock.assert_called_once_with", "popen_mock.assert_called_once_with", "CliRunner", "runner.invoke", "check_output_mock.assert_called_once_with", "mock_profile_session_cache_clear.assert_called", "mock_queue_session_cache_clear.assert_called"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_auth_status | def test_cli_auth_status(fresh_deadline_config):"""Confirm that the CLI status command prints out as expected"""# GIVENprofile_name = "sandbox-us-west-2"config.set_setting("defaults.aws_profile_name", profile_name)with patch.object(api._session, "get_boto3_session") as session_mock, patch.object(api, "get_boto3_session", new=session_mock):# The profile namesession_mock().profile_name = profile_name# WHENrunner = CliRunner()result = runner.invoke(main, ["auth", "status"])# THENassert result.exit_code == 0assert "Profile Name: " in result.outputassert "Source: " in result.outputassert "Status: " in result.outputassert "API Availability: " in result.output | 1 | 14 | 1 | 100 | 3 | 91 | 114 | 91 | fresh_deadline_config | ['result', 'runner', 'profile_name'] | None | {"Assign": 4, "Expr": 2, "With": 1} | 6 | 24 | 6 | ["config.set_setting", "patch.object", "patch.object", "session_mock", "CliRunner", "runner.invoke"] | 0 | [] | The function (test_cli_auth_status) defined within the public class called public.The function start at line 91 and ends at 114. It contains 14 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.set_setting", "patch.object", "patch.object", "session_mock", "CliRunner", "runner.invoke"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_auth_status_json | def test_cli_auth_status_json(fresh_deadline_config):"""Confirm that the CLI status command gives valid json back"""# GIVENprofile_name = "sandbox-us-west-2"expected = {"profile_name": profile_name,"source": "DEADLINE_CLOUD_MONITOR_LOGIN","status": "AUTHENTICATED","api_availability": False,}scoped_config = {"credential_process": "/bin/DeadlineCloudMonitor get-credentials --profile sandbox-us-west-2","monitor_id": "monitor-1g9neezauta8ease","region": "us-west-2",}config.set_setting("defaults.aws_profile_name", profile_name)with patch.object(api._session, "get_boto3_session") as session_mock, patch.object(api, "get_boto3_session", new=session_mock):# The profile namesession_mock().profile_name = profile_name# This configuration includes the IdC profilesession_mock()._session.get_scoped_config.return_value = scoped_configsession_mock()._session.full_config = {"profiles": {profile_name: scoped_config}}# WHENrunner = CliRunner()result = runner.invoke(main, ["auth", "status", "--output", "json"])actual = json.loads(result.output)# THENassert result.exit_code == 0assert actual == expected | 1 | 25 | 1 | 158 | 6 | 117 | 152 | 117 | fresh_deadline_config | ['profile_name', 'scoped_config', 'expected', 'runner', 'result', 'actual'] | None | {"Assign": 9, "Expr": 2, "With": 1} | 9 | 36 | 9 | ["config.set_setting", "patch.object", "patch.object", "session_mock", "session_mock", "session_mock", "CliRunner", "runner.invoke", "json.loads"] | 0 | [] | The function (test_cli_auth_status_json) defined within the public class called public.The function start at line 117 and ends at 152. It contains 25 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", "patch.object", "patch.object", "session_mock", "session_mock", "session_mock", "CliRunner", "runner.invoke", "json.loads"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_submit_simple_json_template | def test_cli_bundle_submit_simple_json_template(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Confirm that CLI bundle submit makes the right create_job call from a simple JSON template."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSE# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Write out some parameterswith open(os.path.join(temp_job_bundle_dir, "parameter_values.yaml"),"w",encoding="utf8",) as f:f.write(MOCK_PARAMETERS_CASES["TEMPLATE_ONLY_JSON"][1])runner = CliRunner()result = runner.invoke(main, ["bundle", "submit", temp_job_bundle_dir])deadline_mock.create_job.assert_called_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,parameters=MOCK_PARAMETERS_CASES["TEMPLATE_ONLY_JSON"][2]["parameters"],# type: ignoretemplate=MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1],templateType="JSON",priority=50,)assert "Submitting to Queue: Mock Queue" in result.output, result.outputassert f"Submitted job bundle:\n {temp_job_bundle_dir}\n" in result.output, result.outputassert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.output, result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.output, result.outputassert result.exit_code == 0, result.output | 1 | 30 | 3 | 235 | 2 | 36 | 75 | 36 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 6, "With": 2} | 11 | 40 | 11 | ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_with"] | 0 | [] | The function (test_cli_bundle_submit_simple_json_template) defined within the public class called public.The function start at line 36 and ends at 75. It contains 30 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [36.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_explicit_parameters | def test_cli_bundle_explicit_parameters(fresh_deadline_config, temp_job_bundle_dir):"""Confirm that --profile, --farm-id, and --queue-id get passed in from the CLI.This test mocks the Session object instead of using moto, to confirm calls with anAWS profile that doesn't exist in the config."""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])with patch.object(boto3, "Session") as session_mock:session_mock().client().create_job.return_value = MOCK_CREATE_JOB_RESPONSEsession_mock().client().get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--profile","NonDefaultProfileName","--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,],)session_mock.assert_called_with(profile_name="NonDefaultProfileName")session_mock().client().create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",priority=50,)assert temp_job_bundle_dir in result.output, result.outputassert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.output, result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.output, result.outputassert result.exit_code == 0, result.output | 1 | 33 | 2 | 203 | 2 | 78 | 122 | 78 | fresh_deadline_config,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 4, "With": 2} | 14 | 45 | 14 | ["open", "os.path.join", "f.write", "patch.object", "client", "session_mock", "client", "session_mock", "CliRunner", "runner.invoke", "session_mock.assert_called_with", "create_job.assert_called_once_with", "client", "session_mock"] | 0 | [] | The function (test_cli_bundle_explicit_parameters) defined within the public class called public.The function start at line 78 and ends at 122. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [78.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", "patch.object", "client", "session_mock", "client", "session_mock", "CliRunner", "runner.invoke", "session_mock.assert_called_with", "create_job.assert_called_once_with", "client", "session_mock"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_priority_retries | def test_cli_bundle_priority_retries(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Confirm that --priority, --max-failed-tasks-count, --max_worker_count and --max-retries-per-task get passed in from the CLI."""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--priority","25","--max-failed-tasks-count","12","--max-retries-per-task","4","--max-worker-count","123",],)assert temp_job_bundle_dir in result.outputassert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.outputdeadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",priority=25,maxFailedTasksCount=12,maxRetriesPerTask=4,maxWorkerCount=123,)assert result.exit_code == 0 | 1 | 40 | 3 | 175 | 2 | 125 | 171 | 125 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 3, "With": 1} | 6 | 47 | 6 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with"] | 0 | [] | The function (test_cli_bundle_priority_retries) defined within the public class called public.The function start at line 125 and ends at 171. It contains 40 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [125.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_job_name | def test_cli_bundle_job_name(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Confirm that --name sets the job name in the template."""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--name","Replacement Name For The Job",],)assert temp_job_bundle_dir in result.outputassert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.outputdeadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=get_minimal_json_job_template("Replacement Name For The Job"),templateType="JSON",priority=50,)assert result.exit_code == 0 | 1 | 31 | 3 | 154 | 2 | 174 | 211 | 174 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 3, "With": 1} | 7 | 38 | 7 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "get_minimal_json_job_template"] | 0 | [] | The function (test_cli_bundle_job_name) defined within the public class called public.The function start at line 174 and ends at 211. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 3 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 ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "get_minimal_json_job_template"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_storage_profile_id | def test_cli_bundle_storage_profile_id(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Confirm that --storage-profile-id sets the ID that the job is submitted with, but does notchange the value of storage profile saved to the configuration file."""PRE_STORAGE_PROFILE_ID = "sp-11223344556677889900abbccddeeff"CLI_STORAGE_PROFILE_ID = "sp-0000000000000000000000000000000"config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Set the storage profile ID in the config; as someone may have by using `deadline config set`config.set_setting("settings.storage_profile_id", PRE_STORAGE_PROFILE_ID)# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()with patch.object(api_module, "get_storage_profile_for_queue"):result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--storage-profile-id",CLI_STORAGE_PROFILE_ID,],)assert temp_job_bundle_dir in result.outputassert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.outputdeadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",priority=50,storageProfileId=CLI_STORAGE_PROFILE_ID,)assert result.exit_code == 0# Force a re-load from disk of the config objectwith patch.object(config.config_file, "_should_read_config", return_value=True):assert config.get_setting("settings.storage_profile_id") == PRE_STORAGE_PROFILE_ID | 1 | 36 | 3 | 212 | 4 | 214 | 262 | 214 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result', 'PRE_STORAGE_PROFILE_ID', 'CLI_STORAGE_PROFILE_ID'] | None | {"Assign": 6, "Expr": 6, "With": 3} | 12 | 49 | 12 | ["config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "CliRunner", "patch.object", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "patch.object", "config.get_setting"] | 0 | [] | The function (test_cli_bundle_storage_profile_id) defined within the public class called public.The function start at line 214 and ends at 262. It contains 36 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [214.0] 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", "open", "os.path.join", "f.write", "CliRunner", "patch.object", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "patch.object", "config.get_setting"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_asset_load_method | def test_cli_bundle_asset_load_method(fresh_deadline_config, deadline_mock, temp_job_bundle_dir, loading_method):"""Verify that asset loading method set on CLI are passed to the CreateJob call.The job attachments S3 bucket is a moto mock, so the verified calls exercise the relevant code for that."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.auto_accept", "true")# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Write out some parameterswith open(os.path.join(temp_job_bundle_dir, "parameter_values.yaml"),"w",encoding="utf8",) as f:f.write(MOCK_PARAMETERS_CASES["TEMPLATE_ONLY_JSON"][1])# Write out the temp directory as an attachmentwith open(os.path.join(temp_job_bundle_dir, "asset_references.json"),"w",encoding="utf8",) as f:data = {"assetReferences": {"inputs": {"directories": [temp_job_bundle_dir],"filenames": [],},"outputs": {"directories": [temp_job_bundle_dir]},}}json.dump(data, f)deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSEparams = ["bundle", "submit", temp_job_bundle_dir]# None case represents not setting the parameterif loading_method is not None:params += ["--job-attachments-file-system", loading_method]runner = CliRunner()result = runner.invoke(main, params)expected_loading_method = (loading_methodif loading_method is not Noneelse config.get_setting("defaults.job_attachments_file_system"))assert temp_job_bundle_dir in result.output, result.outputdeadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,parameters=MOCK_PARAMETERS_CASES["TEMPLATE_ONLY_JSON"][2]["parameters"],# type: ignoretemplate=MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1],templateType="JSON",attachments={"fileSystem": expected_loading_method,"manifests": [{"rootPath": temp_job_bundle_dir,"rootPathFormat": "windows" if os.name == "nt" else "posix","inputManifestPath": ANY,"inputManifestHash": ANY,"outputRelativeDirectories": ["."],}],},priority=50,)assert MOCK_CREATE_JOB_RESPONSE["jobId"] in result.output, result.outputassert MOCK_GET_JOB_RESPONSE["lifecycleStatusMessage"] in result.output, result.outputassert result.exit_code == 0, result.output | 4 | 65 | 4 | 379 | 5 | 266 | 348 | 266 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir,loading_method | ['expected_loading_method', 'runner', 'params', 'result', 'data'] | None | {"Assign": 7, "AugAssign": 1, "Expr": 8, "If": 1, "With": 3} | 17 | 83 | 17 | ["config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "CliRunner", "runner.invoke", "config.get_setting", "deadline_mock.create_job.assert_called_once_with", "pytest.mark.parametrize"] | 0 | [] | The function (test_cli_bundle_asset_load_method) defined within the public class called public.The function start at line 266 and ends at 348. It contains 65 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [266.0] and does not return any value. It declares 17.0 functions, and It has 17.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "CliRunner", "runner.invoke", "config.get_setting", "deadline_mock.create_job.assert_called_once_with", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_job_parameter_from_cli | def test_cli_bundle_job_parameter_from_cli(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that job parameters specified at the CLI are passed to the CreateJob call"""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--parameter","sceneFile=/path/to/scenefile","--parameter","priority=90","--priority","45","--submitter-name","MyDCC",],)deadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",parameters={"sceneFile": {"string": "/path/to/scenefile"},"priority": {"int": "90"},},priority=45,)deadline_mock.get_deadline_cloud_library_telemetry_client.return_value.record_event.assert_any_call(event_type="com.amazon.rum.deadline.submission",event_details={"submitter_name": "MyDCC"},from_gui=False,)assert result.exit_code == 0, result.output | 1 | 45 | 3 | 191 | 2 | 351 | 404 | 351 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 4, "With": 1} | 7 | 54 | 7 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "deadline_mock.get_deadline_cloud_library_telemetry_client.return_value.record_event.assert_any_call"] | 0 | [] | The function (test_cli_bundle_job_parameter_from_cli) defined within the public class called public.The function start at line 351 and ends at 404. It contains 45 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [351.0] and does not return any value. It declares 7.0 functions, and It has 7.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with", "deadline_mock.get_deadline_cloud_library_telemetry_client.return_value.record_event.assert_any_call"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_empty_job_parameter_from_cli | def test_cli_bundle_empty_job_parameter_from_cli(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that an empty job parameter specified at the CLI are passed to the CreateJob call"""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--parameter","sceneFile=",],)assert deadline_mock.create_job.mock_calls == [call(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",parameters={"sceneFile": {"string": ""},},priority=50,)], result.outputassert result.exit_code == 0, result.output | 1 | 35 | 3 | 153 | 2 | 407 | 449 | 407 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 2, "With": 1} | 6 | 43 | 6 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "call"] | 0 | [] | The function (test_cli_bundle_empty_job_parameter_from_cli) defined within the public class called public.The function start at line 407 and ends at 449. It contains 35 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [407.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "call"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_job_parameter_with_equals_from_cli | def test_cli_bundle_job_parameter_with_equals_from_cli(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that a job parameter value with an '=' in it is passed correctly to the CreateJob call"""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--parameter","sceneFile=this=is=a=test",],)deadline_mock.create_job.assert_called_once_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=ANY,templateType="JSON",parameters={"sceneFile": {"string": "this=is=a=test"},},priority=50,)assert result.exit_code == 0, result.output | 1 | 33 | 3 | 144 | 2 | 452 | 492 | 452 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 3, "With": 1} | 6 | 41 | 6 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with"] | 0 | [] | The function (test_cli_bundle_job_parameter_with_equals_from_cli) defined within the public class called public.The function start at line 452 and ends at 492. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [452.0] and does not return any value. It declares 6.0 functions, and It has 6.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_invalid_job_parameter | def test_cli_bundle_invalid_job_parameter(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that a badly formatted parameter value (without "Key=Value") throws an error"""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--parameter","BadParam",],)assert 'Parameters must be provided in the format "ParamName=Value"' in result.outputassert result.exit_code == 2 | 1 | 24 | 3 | 106 | 2 | 495 | 525 | 495 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 2, "With": 1} | 5 | 31 | 5 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke"] | 0 | [] | The function (test_cli_bundle_invalid_job_parameter) defined within the public class called public.The function start at line 495 and ends at 525. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [495.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_invalid_job_parameter_name | def test_cli_bundle_invalid_job_parameter_name(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that a non-identifier parameter name raises an error."""# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,"--parameter","Param*Name=Value",],)assert "Parameter names must be alphanumeric Open Job Description identifiers." in result.outputassert result.exit_code == 2 | 1 | 24 | 3 | 106 | 2 | 528 | 558 | 528 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 4, "Expr": 2, "With": 1} | 5 | 31 | 5 | ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke"] | 0 | [] | The function (test_cli_bundle_invalid_job_parameter_name) defined within the public class called public.The function start at line 528 and ends at 558. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [528.0] and does not return any value. It declares 5.0 functions, and It has 5.0 functions called inside which are ["open", "os.path.join", "f.write", "CliRunner", "runner.invoke"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_accept_upload_confirmation | def test_cli_bundle_accept_upload_confirmation(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that when the user accepts the job attachments upload confirmationthat CreateJob is called properly still."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.auto_accept", "false")# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Write a single asset pathwith open(os.path.join(temp_job_bundle_dir, "asset_references.yaml"), "w", encoding="utf8") as f:data = {"assetReferences": {"inputs": {"directories": [temp_job_bundle_dir],"filenames": [],},"outputs": {"directories": [temp_job_bundle_dir]},}}json.dump(data, f)deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,],input="y",)deadline_mock.create_job.assert_called_with(farmId=MOCK_FARM_ID,queueId=MOCK_QUEUE_ID,template=MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1],templateType="JSON",attachments=ANY,priority=50,)assert result.exit_code == 0, result.output | 1 | 46 | 3 | 230 | 3 | 561 | 617 | 561 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result', 'data'] | None | {"Assign": 5, "Expr": 7, "With": 2} | 12 | 57 | 12 | ["config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_with"] | 0 | [] | The function (test_cli_bundle_accept_upload_confirmation) defined within the public class called public.The function start at line 561 and ends at 617. It contains 46 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [561.0] 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", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_with"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_reject_upload_confirmation | def test_cli_bundle_reject_upload_confirmation(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Verify that when the user rejects the job attachments upload confirmationthat no further action is taken after that point, and that a failure CLI exit code results."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.auto_accept", "false")# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Write a single asset pathwith open(os.path.join(temp_job_bundle_dir, "asset_references.yaml"), "w", encoding="utf8") as f:data = {"assetReferences": {"inputs": {"directories": [temp_job_bundle_dir],"filenames": [],},"outputs": {"directories": [temp_job_bundle_dir]},}}json.dump(data, f)deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSEwith patch.object(S3AssetManager, "upload_assets") as mock_upload_assets:runner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,"--farm-id",MOCK_FARM_ID,"--queue-id",MOCK_QUEUE_ID,],input="n",)mock_upload_assets.assert_not_called()assert result.exit_code == 1 | 1 | 40 | 3 | 206 | 3 | 620 | 670 | 620 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result', 'data'] | None | {"Assign": 5, "Expr": 7, "With": 3} | 13 | 51 | 13 | ["config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "patch.object", "CliRunner", "runner.invoke", "mock_upload_assets.assert_not_called"] | 0 | [] | The function (test_cli_bundle_reject_upload_confirmation) defined within the public class called public.The function start at line 620 and ends at 670. It contains 40 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [620.0] 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", "open", "os.path.join", "f.write", "open", "os.path.join", "json.dump", "patch.object", "CliRunner", "runner.invoke", "mock_upload_assets.assert_not_called"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_gui_submit_submitter_name | def test_gui_submit_submitter_name(_mock_context):"""Verify that the --submitter-name arg gets passed through correctly"""# Unconventional mocking pattern because of how the function is imported in codemock_job_bundle_submitter = Mock()sys.modules["deadline.client.ui.job_bundle_submitter"] = mock_job_bundle_submittermock_job_bundle_submitter.show_job_bundle_submitterrunner = CliRunner()runner.invoke(main,["bundle", "gui-submit", "--browse", "--submitter-name", "MyDCC"],)_args, kwargs = mock_job_bundle_submitter.show_job_bundle_submitter.call_argsassert kwargs["submitter_name"] == "MyDCC" | 1 | 11 | 1 | 62 | 2 | 674 | 690 | 674 | _mock_context | ['runner', 'mock_job_bundle_submitter'] | None | {"Assign": 4, "Expr": 3} | 4 | 17 | 4 | ["Mock", "CliRunner", "runner.invoke", "patch"] | 0 | [] | The function (test_gui_submit_submitter_name) defined within the public class called public.The function start at line 674 and ends at 690. 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 4.0 functions, and It has 4.0 functions called inside which are ["Mock", "CliRunner", "runner.invoke", "patch"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_bundle_submit_with_target_task_run_status | def test_bundle_submit_with_target_task_run_status(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Test that the --target-task-run-status CLI option is passed through correctly."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit","--target-task-run-status","SUSPENDED",temp_job_bundle_dir,],)assert result.exit_code == 0deadline_mock.create_job.assert_called_once()_, kwargs = deadline_mock.create_job.call_argsassert kwargs["targetTaskRunStatus"] == "SUSPENDED" | 1 | 24 | 3 | 131 | 2 | 693 | 724 | 693 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 5, "Expr": 5, "With": 1} | 8 | 32 | 8 | ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once"] | 0 | [] | The function (test_bundle_submit_with_target_task_run_status) defined within the public class called public.The function start at line 693 and ends at 724. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [693.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_bundle_submit_without_target_task_run_status | def test_bundle_submit_without_target_task_run_status(fresh_deadline_config, deadline_mock, temp_job_bundle_dir):"""Test that when --target-task-run-status is not specified, None is passed."""config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])deadline_mock.create_job.return_value = MOCK_CREATE_JOB_RESPONSEdeadline_mock.get_job.return_value = MOCK_GET_JOB_RESPONSErunner = CliRunner()result = runner.invoke(main,["bundle","submit",temp_job_bundle_dir,],)assert result.exit_code == 0deadline_mock.create_job.assert_called_once()_, kwargs = deadline_mock.create_job.call_argsassert "targetTaskRunStatus" not in kwargs | 1 | 22 | 3 | 125 | 2 | 727 | 756 | 727 | fresh_deadline_config,deadline_mock,temp_job_bundle_dir | ['runner', 'result'] | None | {"Assign": 5, "Expr": 5, "With": 1} | 8 | 30 | 8 | ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once"] | 0 | [] | The function (test_bundle_submit_without_target_task_run_status) defined within the public class called public.The function start at line 727 and ends at 756. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [727.0] and does not return any value. It declares 8.0 functions, and It has 8.0 functions called inside which are ["config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "CliRunner", "runner.invoke", "deadline_mock.create_job.assert_called_once"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | normalize_job_bundle_timestamps | def normalize_job_bundle_timestamps(job_bundle_dir):"""Sets the timestamps of all the files in a job bundle directory to one fixed value."""for root, _, files in os.walk(job_bundle_dir):for filename in files:full_filename = os.path.join(root, filename)os.utime(full_filename, (1756710000, 1756710000)) | 3 | 5 | 1 | 49 | 1 | 30 | 35 | 30 | job_bundle_dir | ['full_filename'] | None | {"Assign": 1, "Expr": 2, "For": 2} | 3 | 6 | 3 | ["os.walk", "os.path.join", "os.utime"] | 1 | ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"] | The function (normalize_job_bundle_timestamps) defined within the public class called public.The function start at line 30 and ends at 35. It contains 5 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 3.0 functions, It has 3.0 functions called inside which are ["os.walk", "os.path.join", "os.utime"], 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_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | normalize_snapshot | def normalize_snapshot(snapshot_dir):"""Normalizes the platform-specific directories into named tokens, and '\\' on Windows to '/'"""# Normalize to LF line endings, and then on Windows back to CRLF for consistent comparison with git checkout of snapshotreplacements: list[tuple[str, str]] = []if os.name != "nt":replacements.append(("\r\n", "\n"))with open(_get_long_path_compatible_path(snapshot_dir / "create_job_args.json"), encoding="utf-8") as fh:create_job_args = json.load(fh)# Process all the manifests to figure out renamings that normalize the snapshotfor index, manifest in enumerate(create_job_args["attachments"]["manifests"]):root_path = manifest["rootPath"]replacements.append((root_path + os.sep, f"ROOT_PATH_{index}/"))if os.name == "nt":# Also match double-\\ patterns for JSON-encoded values on Windowsreplacements.append((root_path.replace(os.sep, 2 * os.sep) + 2 * os.sep, f"ROOT_PATH_{index}/"))replacements.append((root_path, f"ROOT_PATH_{index}"))if os.name == "nt":# Also match double-\\ patterns for JSON-encoded values on Windowsreplacements.append((root_path.replace(os.sep, 2 * os.sep), f"ROOT_PATH_{index}"))manifest_path = manifest["inputManifestPath"]manifest_name = manifest_path.rsplit("/", 1)[-1]replacements.append((manifest_name, f"MANIFEST_NAME_{index}"))replacements.append((f'"rootPathFormat": "{manifest["rootPathFormat"]}"',f'"rootPathFormat": "ROOT_PATH_FORMAT_{index}"',))# Rename the manifest file so the snapshot remains self-consistentmanifest_old_name = _get_long_path_compatible_path(snapshot_dir / "Manifests" / manifest_path)manifest_new_name = _get_long_path_compatible_path((snapshot_dir / "Manifests" / manifest_path).parent / f"MANIFEST_NAME_{index}")os.rename(manifest_old_name, manifest_new_name)# Process every file in the snapshot directory to apply the replacementsfor filename in os.listdir(snapshot_dir):full_filename = snapshot_dir / filenameif not os.path.isfile(_get_long_path_compatible_path(full_filename)):continuewith open(_get_long_path_compatible_path(full_filename), "rb") as f:contents = f.read()for src, dst in replacements:contents = contents.replace(src.encode("utf-8"), dst.encode("utf-8"))with open(_get_long_path_compatible_path(full_filename), "wb") as f:f.write(contents) | 8 | 44 | 1 | 353 | 8 | 38 | 94 | 38 | snapshot_dir | ['manifest_path', 'manifest_new_name', 'root_path', 'full_filename', 'create_job_args', 'manifest_old_name', 'manifest_name', 'contents'] | None | {"AnnAssign": 1, "Assign": 9, "Expr": 10, "For": 3, "If": 4, "With": 3} | 29 | 57 | 29 | ["replacements.append", "open", "_get_long_path_compatible_path", "json.load", "enumerate", "replacements.append", "replacements.append", "root_path.replace", "replacements.append", "replacements.append", "root_path.replace", "manifest_path.rsplit", "replacements.append", "replacements.append", "_get_long_path_compatible_path", "_get_long_path_compatible_path", "os.rename", "os.listdir", "os.path.isfile", "_get_long_path_compatible_path", "open", "_get_long_path_compatible_path", "f.read", "contents.replace", "src.encode", "dst.encode", "open", "_get_long_path_compatible_path", "f.write"] | 1 | ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"] | The function (normalize_snapshot) defined within the public class called public.The function start at line 38 and ends at 94. It contains 44 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value. It declares 29.0 functions, It has 29.0 functions called inside which are ["replacements.append", "open", "_get_long_path_compatible_path", "json.load", "enumerate", "replacements.append", "replacements.append", "root_path.replace", "replacements.append", "replacements.append", "root_path.replace", "manifest_path.rsplit", "replacements.append", "replacements.append", "_get_long_path_compatible_path", "_get_long_path_compatible_path", "os.rename", "os.listdir", "os.path.isfile", "_get_long_path_compatible_path", "open", "_get_long_path_compatible_path", "f.read", "contents.replace", "src.encode", "dst.encode", "open", "_get_long_path_compatible_path", "f.write"], 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_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | assert_directories_equal | def assert_directories_equal(snapshot_dir, expected_dir):# Walk through the two directories together and comparesnap_extra: list[str] = []exp_extra: list[str] = []files_differ: list[tuple[str, str]] = []for (snap_root, snap_dirs, snap_files), (exp_root, exp_dirs, exp_files) in zip(os.walk(snapshot_dir), os.walk(expected_dir)):# Find directory mismatchessnap_extra.extend(os.path.join(snap_root, dir) for dir in (set(snap_dirs) - set(exp_dirs)))exp_extra.extend(os.path.join(exp_root, dir) for dir in (set(exp_dirs) - set(snap_dirs)))# Update os.walk to intersection of dirssnap_dirs[:] = exp_dirs[:] = set(snap_dirs).intersection(exp_dirs)# Find file mismatchessnap_extra.extend(os.path.join(snap_root, file) for file in (set(snap_files) - set(exp_files)))exp_extra.extend(os.path.join(exp_root, file) for file in (set(exp_files) - set(snap_files)))# Compare the filesfor file in set(snap_files).intersection(exp_files):with open(_get_long_path_compatible_path(os.path.join(snap_root, file)), "rb") as f:contents1 = f.read()with open(_get_long_path_compatible_path(os.path.join(exp_root, file)), "rb") as f:contents2 = f.read()if contents1 != contents2:files_differ.append((os.path.join(snap_root, file), os.path.join(exp_root, file)))if files_differ:for snap_file, exp_file in files_differ:with open(snap_file, "r", encoding="utf-8") as snap_fh, open(exp_file, "r", encoding="utf-8") as exp_fh:for line in difflib.unified_diff(snap_fh.readlines(), exp_fh.readlines(), fromfile=snap_file, tofile=exp_file):print(line, end="")print()assert {"snap_extra": snap_extra, "exp_extra": exp_extra, "files_differ": files_differ} == {"snap_extra": [],"exp_extra": [],"files_differ": [],} | 11 | 38 | 2 | 420 | 2 | 97 | 141 | 97 | snapshot_dir,expected_dir | ['contents2', 'contents1'] | None | {"AnnAssign": 3, "Assign": 3, "Expr": 7, "For": 4, "If": 2, "With": 3} | 41 | 45 | 41 | ["zip", "os.walk", "os.walk", "snap_extra.extend", "os.path.join", "set", "set", "exp_extra.extend", "os.path.join", "set", "set", "intersection", "set", "snap_extra.extend", "os.path.join", "set", "set", "exp_extra.extend", "os.path.join", "set", "set", "intersection", "set", "open", "_get_long_path_compatible_path", "os.path.join", "f.read", "open", "_get_long_path_compatible_path", "os.path.join", "f.read", "files_differ.append", "os.path.join", "os.path.join", "open", "open", "difflib.unified_diff", "snap_fh.readlines", "exp_fh.readlines", "print", "print"] | 1 | ["_.content.gdrive.MyDrive.Phd_Thesis.Dataset_Creation.Output.Cloned_Repo_3.94876780_aws_deadline_deadline_cloud.test.unit.deadline_client.cli.test_cli_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"] | The function (assert_directories_equal) defined within the public class called public.The function start at line 97 and ends at 141. It contains 38 lines of code and it has a cyclomatic complexity of 11. It takes 2 parameters, represented as [97.0] and does not return any value. It declares 41.0 functions, It has 41.0 functions called inside which are ["zip", "os.walk", "os.walk", "snap_extra.extend", "os.path.join", "set", "set", "exp_extra.extend", "os.path.join", "set", "set", "intersection", "set", "snap_extra.extend", "os.path.join", "set", "set", "exp_extra.extend", "os.path.join", "set", "set", "intersection", "set", "open", "_get_long_path_compatible_path", "os.path.join", "f.read", "open", "_get_long_path_compatible_path", "os.path.join", "f.read", "files_differ.append", "os.path.join", "os.path.join", "open", "open", "difflib.unified_diff", "snap_fh.readlines", "exp_fh.readlines", "print", "print"], 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_bundle_submit_debug_snapshot_py.test_cli_bundle_submit_debug_snapshot"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_submit_debug_snapshot | def test_cli_bundle_submit_debug_snapshot(fresh_deadline_config, deadline_mock, tmp_path):"""Confirm that CLI bundle submit makes the right create_job call from a simple JSON template."""# Make sure the temporary path has no symlinkstmp_path = tmp_path.resolve()config.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)job_bundle_dir = Path(__file__).parent / "test_data" / "job_bundle_with_data"job_bundle_dir = job_bundle_dir.resolve()expected_snapshot_dir = Path(__file__).parent / "test_data" / "job_bundle_with_data_snapshot"expected_snapshot_dir = expected_snapshot_dir.resolve()normalize_job_bundle_timestamps(job_bundle_dir)# You can temporarily set this to True to regenerate the snapshotregenerate_snapshot = Falseif regenerate_snapshot:tmp_path = expected_snapshot_dirshutil.rmtree(tmp_path)with patch.object(deadline.job_attachments.models,"_generate_random_guid",return_value="00000000000000000000000000000000",):runner = CliRunner()result = runner.invoke(main,["bundle","submit",str(job_bundle_dir),"--yes","--save-debug-snapshot",str(tmp_path),],)deadline_mock.create_job.assert_not_called()assert "Snapshotting submission to Queue: Mock Queue" in result.output, result.outputassert "Submitting to Queue: Mock Queue" not in result.output, result.outputassert result.exit_code == 0, result.outputnormalize_snapshot(tmp_path)assert_directories_equal(tmp_path, expected_snapshot_dir) | 2 | 36 | 3 | 192 | 6 | 144 | 191 | 144 | fresh_deadline_config,deadline_mock,tmp_path | ['job_bundle_dir', 'tmp_path', 'expected_snapshot_dir', 'regenerate_snapshot', 'runner', 'result'] | None | {"Assign": 9, "Expr": 8, "If": 1, "With": 1} | 17 | 48 | 17 | ["tmp_path.resolve", "config.set_setting", "config.set_setting", "Path", "job_bundle_dir.resolve", "Path", "expected_snapshot_dir.resolve", "normalize_job_bundle_timestamps", "shutil.rmtree", "patch.object", "CliRunner", "runner.invoke", "str", "str", "deadline_mock.create_job.assert_not_called", "normalize_snapshot", "assert_directories_equal"] | 0 | [] | The function (test_cli_bundle_submit_debug_snapshot) defined within the public class called public.The function start at line 144 and ends at 191. It contains 36 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [144.0] and does not return any value. It declares 17.0 functions, and It has 17.0 functions called inside which are ["tmp_path.resolve", "config.set_setting", "config.set_setting", "Path", "job_bundle_dir.resolve", "Path", "expected_snapshot_dir.resolve", "normalize_job_bundle_timestamps", "shutil.rmtree", "patch.object", "CliRunner", "runner.invoke", "str", "str", "deadline_mock.create_job.assert_not_called", "normalize_snapshot", "assert_directories_equal"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_filter_redundant_known_paths | def test_filter_redundant_known_paths(input, expected):assert sorted(_filter_redundant_known_paths(input)) == expectedif os.name == "nt":assert sorted(_filter_redundant_known_paths(path.replace("/", "\\") for path in input)) == [path.replace("/", "\\") for path in expected]assert sorted(_filter_redundant_known_paths("C:" + path.replace("/", "\\") for path in input)) == ["C:" + path.replace("/", "\\") for path in expected] | 6 | 9 | 2 | 96 | 0 | 40 | 48 | 40 | input,expected | [] | None | {"If": 1} | 11 | 9 | 11 | ["sorted", "_filter_redundant_known_paths", "sorted", "_filter_redundant_known_paths", "path.replace", "path.replace", "sorted", "_filter_redundant_known_paths", "path.replace", "path.replace", "pytest.mark.parametrize"] | 0 | [] | The function (test_filter_redundant_known_paths) defined within the public class called public.The function start at line 40 and ends at 48. It contains 9 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [40.0] and does not return any value. It declares 11.0 functions, and It has 11.0 functions called inside which are ["sorted", "_filter_redundant_known_paths", "sorted", "_filter_redundant_known_paths", "path.replace", "path.replace", "sorted", "_filter_redundant_known_paths", "path.replace", "path.replace", "pytest.mark.parametrize"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_known_paths_combine | def test_cli_bundle_known_paths_combine(fresh_deadline_config, temp_job_bundle_dir):"""Test that the CLI combines known upload paths from both the CLI parameterand the configuration setting."""# Set up configurationconfig.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.auto_accept", "true")# Set known paths in config using OS-specific path separatorconfig_path1 = "/path/from/config/1" if os.name != "nt" else "C:\\path\\from\\config\\1"config_path2 = "/path/from/config/2" if os.name != "nt" else "C:\\path\\from\\config\\2"config.set_setting("settings.known_asset_paths", os.pathsep.join([config_path1, config_path2]))# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Create a file outside the job bundle directorywith tempfile.NamedTemporaryFile(delete=False) as temp_file:temp_file.write(b"test content")external_file_path = temp_file.nametry:# Create asset references pointing to the external filewith open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": {"inputs": {"filenames": [external_file_path],"directories": [],},"outputs": {"directories": []},}},f,)with patch_calls_for_create_job_from_job_bundle() as mock:# Create OS-specific CLI pathscli_path1 = "/path/from/cli/1" if os.name != "nt" else "C:\\path\\from\\cli\\1"cli_path2 = os.path.dirname(external_file_path)# Run the CLI command with known upload pathsrunner = CliRunner()result = runner.invoke(main,["bundle","submit","--yes",temp_job_bundle_dir,"--known-asset-path",cli_path1,"--known-asset-path",cli_path2,],)# Verify the command succeededassert result.exit_code == 0, result.output# Verify create_job_from_job_bundle was called with combined pathsmock.create_job_from_job_bundle.assert_called_once()_, kwargs = mock.create_job_from_job_bundle.call_argsassert "known_asset_paths" in kwargsknown_paths = kwargs["known_asset_paths"]assert cli_path1 in known_paths, result.outputassert cli_path2 in known_paths, result.outputassert config_path1 not in known_paths, result.outputassert config_path2 not in known_paths, result.output# Check that both the CLI and config paths are provided to generate_message_for_asset_pathsmock.generate_message_for_asset_paths.assert_called_once()(_, _, known_paths), _ = mock.generate_message_for_asset_paths.call_argsassert cli_path1 in known_paths, result.outputassert cli_path2 in known_paths, result.outputassert config_path1 in known_paths, result.outputassert config_path2 in known_paths, result.outputfinally:# Clean up the temporary fileos.unlink(external_file_path) | 5 | 62 | 2 | 389 | 8 | 51 | 136 | 51 | fresh_deadline_config,temp_job_bundle_dir | ['config_path1', 'cli_path1', 'runner', 'known_paths', 'result', 'config_path2', 'cli_path2', 'external_file_path'] | None | {"Assign": 10, "Expr": 11, "Try": 1, "With": 4} | 20 | 86 | 20 | ["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "os.pathsep.join", "open", "os.path.join", "f.write", "tempfile.NamedTemporaryFile", "temp_file.write", "open", "os.path.join", "json.dump", "patch_calls_for_create_job_from_job_bundle", "os.path.dirname", "CliRunner", "runner.invoke", "mock.create_job_from_job_bundle.assert_called_once", "mock.generate_message_for_asset_paths.assert_called_once", "os.unlink"] | 0 | [] | The function (test_cli_bundle_known_paths_combine) defined within the public class called public.The function start at line 51 and ends at 136. It contains 62 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [51.0] and does not return any value. It declares 20.0 functions, and It has 20.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "os.pathsep.join", "open", "os.path.join", "f.write", "tempfile.NamedTemporaryFile", "temp_file.write", "open", "os.path.join", "json.dump", "patch_calls_for_create_job_from_job_bundle", "os.path.dirname", "CliRunner", "runner.invoke", "mock.create_job_from_job_bundle.assert_called_once", "mock.generate_message_for_asset_paths.assert_called_once", "os.unlink"]. |
aws-deadline_deadline-cloud | public | public | 0 | 0 | test_cli_bundle_storage_profile_known_paths | def test_cli_bundle_storage_profile_known_paths(fresh_deadline_config, temp_job_bundle_dir):"""Test that known paths from a storage profile are included when submitting a job bundle."""# Set up configurationconfig.set_setting("defaults.farm_id", MOCK_FARM_ID)config.set_setting("defaults.queue_id", MOCK_QUEUE_ID)config.set_setting("settings.auto_accept", "true")# Set a storage profile ID in the configstorage_profile_id = "mock-storage-profile-id"config.set_setting("settings.storage_profile_id", storage_profile_id)# Write a JSON templatewith open(os.path.join(temp_job_bundle_dir, "template.json"), "w", encoding="utf8") as f:f.write(MOCK_JOB_TEMPLATE_CASES["MINIMAL_JSON"][1])# Create a file outside the job bundle directorywith tempfile.NamedTemporaryFile(delete=False) as temp_file:temp_file.write(b"test content")external_file_path = temp_file.nametry:# Create asset references pointing to the external filewith open(os.path.join(temp_job_bundle_dir, "asset_references.json"), "w", encoding="utf8") as f:json.dump({"assetReferences": {"inputs": {"filenames": [external_file_path],"directories": [],},"outputs": {"directories": []},}},f,)# Create a mock storage profile with file system locationslocal_storage_profile_path = os.path.dirname(external_file_path)shared_storage_profile_path = ("/shared/path/from/storage/profile"if os.name != "nt"else "C:\\shared\\path\\from\\storage\\profile")# Create the StorageProfile object directlyos_family = "WINDOWS" if os.name == "nt" else "LINUX"storage_profile_response = {"storageProfileId": storage_profile_id,"displayName": "Mock Storage Profile","osFamily": os_family,"fileSystemLocations": [{"name": "mock-local-location","path": local_storage_profile_path,"type": "LOCAL",},{"name": "mock-shared-location","path": shared_storage_profile_path,"type": "SHARED",},],}with patch_calls_for_create_job_from_job_bundle() as mock:mock.get_boto3_client().get_storage_profile_for_queue.return_value = (storage_profile_response)# Run the CLI command with known upload pathsrunner = CliRunner()result = runner.invoke(main,["bundle","submit","--yes",temp_job_bundle_dir,],)# Verify the command succeededassert result.exit_code == 0, result.output# Verify get_storage_profile_for_queue was called with correct parametersassert mock.get_boto3_client().get_storage_profile_for_queue.mock_calls == [call(farmId=MOCK_FARM_ID, queueId=MOCK_QUEUE_ID, storageProfileId=storage_profile_id)], result.output# Verify create_job_from_job_bundle was calledmock.create_job_from_job_bundle.assert_called_once()_, kwargs = mock.create_job_from_job_bundle.call_argsassert "known_asset_paths" in kwargsknown_paths = kwargs["known_asset_paths"]# Verify the storage profile path is not in the known paths passed to create_job_in_job_bundleassert local_storage_profile_path not in known_paths, result.outputassert shared_storage_profile_path not in known_paths, result.output# Check that the LOCAL storage profile paths are provided to generate_message_for_asset_pathsmock.generate_message_for_asset_paths.assert_called_once()(_, _, known_paths), _ = mock.generate_message_for_asset_paths.call_argsassert local_storage_profile_path in known_paths, result.output# The SHARED storage location should not be in the known paths listassert shared_storage_profile_path not in known_paths, result.outputfinally:# Clean up the temporary fileos.unlink(external_file_path) | 4 | 83 | 2 | 428 | 9 | 139 | 252 | 139 | fresh_deadline_config,temp_job_bundle_dir | ['local_storage_profile_path', 'storage_profile_response', 'storage_profile_id', 'os_family', 'shared_storage_profile_path', 'runner', 'known_paths', 'result', 'external_file_path'] | None | {"Assign": 12, "Expr": 11, "Try": 1, "With": 4} | 22 | 114 | 22 | ["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "tempfile.NamedTemporaryFile", "temp_file.write", "open", "os.path.join", "json.dump", "os.path.dirname", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "CliRunner", "runner.invoke", "mock.get_boto3_client", "call", "mock.create_job_from_job_bundle.assert_called_once", "mock.generate_message_for_asset_paths.assert_called_once", "os.unlink"] | 0 | [] | The function (test_cli_bundle_storage_profile_known_paths) defined within the public class called public.The function start at line 139 and ends at 252. It contains 83 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [139.0] and does not return any value. It declares 22.0 functions, and It has 22.0 functions called inside which are ["config.set_setting", "config.set_setting", "config.set_setting", "config.set_setting", "open", "os.path.join", "f.write", "tempfile.NamedTemporaryFile", "temp_file.write", "open", "os.path.join", "json.dump", "os.path.dirname", "patch_calls_for_create_job_from_job_bundle", "mock.get_boto3_client", "CliRunner", "runner.invoke", "mock.get_boto3_client", "call", "mock.create_job_from_job_bundle.assert_called_once", "mock.generate_message_for_asset_paths.assert_called_once", "os.unlink"]. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.