From 4a3ce2a161b4483b7441cdd59bdba46840aaa510 Mon Sep 17 00:00:00 2001 From: YutoTakaki Date: Sat, 12 Aug 2023 06:23:55 +0000 Subject: [PATCH] add mock for Quantum_Neuron --- test/integ_tests/default_mocks/default_mocks.py | 10 +++++++--- test/integ_tests/mock_utils.py | 6 +++--- test/integ_tests/textbook/Quantum_Neuron_mocks.py | 8 ++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/test/integ_tests/default_mocks/default_mocks.py b/test/integ_tests/default_mocks/default_mocks.py index f720da2f..400b93cf 100644 --- a/test/integ_tests/default_mocks/default_mocks.py +++ b/test/integ_tests/default_mocks/default_mocks.py @@ -1,10 +1,14 @@ def pre_run_inject(mock_utils): print("This is inside default_mocks.py") - + mocker = mock_utils.Mocker() mock_utils.mock_default_device_calls(mocker) - mocker.set_get_default_jobs_role() - mocker.set_create_job_result({"jobArn": "arn:aws:braket:us-east-1:000000:job/TestARN"}) + mocker.set_get_default_jobs_role('arn:aws:iam::000000:role/service-role/TestRole') + mocker.set_create_job_result( + { + "jobArn": "arn:aws:braket:us-east-1:000000:job/TestARN" + } + ) def post_run(tb): diff --git a/test/integ_tests/mock_utils.py b/test/integ_tests/mock_utils.py index 01a92fa6..b30f1ef3 100644 --- a/test/integ_tests/mock_utils.py +++ b/test/integ_tests/mock_utils.py @@ -31,10 +31,10 @@ def set_create_quantum_task_result(self, result): # test def set_create_job_result(self, result): self._wrapper.boto_client.create_job.return_value = result - + # test - def set_get_default_jobs_role(self): - self._wrapper.boto_client.get_default_jobs_role.return_value = mock.Mock() + def set_get_default_jobs_role(self, result): + self._wrapper.boto_client.get_default_jobs_role.return_value = result def set_get_quantum_task_result(self, result): self._wrapper.boto_client.get_quantum_task.return_value = result diff --git a/test/integ_tests/textbook/Quantum_Neuron_mocks.py b/test/integ_tests/textbook/Quantum_Neuron_mocks.py index 05c716a2..a7945a93 100644 --- a/test/integ_tests/textbook/Quantum_Neuron_mocks.py +++ b/test/integ_tests/textbook/Quantum_Neuron_mocks.py @@ -3,8 +3,12 @@ def pre_run_inject(mock_utils): mocker = mock_utils.Mocker() mock_utils.mock_default_device_calls(mocker) - mocker.set_create_job_result({"jobArn": "arn:aws:braket:us-east-1:000000:job/TestARN"}) - mocker.__iter__.return_value = [] + mocker.set_get_default_jobs_role('arn:aws:iam::000000:role/service-role/TestRole') + mocker.set_create_job_result( + { + "jobArn": "arn:aws:braket:us-east-1:000000:job/TestARN" + } + ) mocker.set_task_result_return(mock_utils.read_file("quantum_neuron_results.json", __file__))