@@ -46,16 +46,16 @@ class TestPrepareDependencyArchive:
4646 EXPECTED_DOCKER_RUN_CMD = (
4747 "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm "
4848 "-v /tmp/test_dir:/workspace "
49- "datacloud-custom-code-dependency-builder "
50- '/bin/bash -c "./build_native_dependencies.sh"'
49+ "datacloud-custom-code-dependency-builder"
5150 )
5251
5352 @patch ("datacustomcode.deploy.cmd_output" )
5453 @patch ("datacustomcode.deploy.shutil.copy" )
5554 @patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
5655 @patch ("datacustomcode.deploy.os.path.join" )
56+ @patch ("datacustomcode.deploy.os.makedirs" )
5757 def test_prepare_dependency_archive_image_exists (
58- self , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
58+ self , mock_makedirs , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
5959 ):
6060 """Test prepare_dependency_archive when Docker image already exists."""
6161 # Mock the temporary directory context manager
@@ -85,15 +85,19 @@ def test_prepare_dependency_archive_image_exists(
8585 # Verify docker run command was called
8686 mock_cmd_output .assert_any_call (self .EXPECTED_DOCKER_RUN_CMD )
8787
88+ # Verify archives directory was created
89+ mock_makedirs .assert_called_once_with ("payload/archives" , exist_ok = True )
90+
8891 # Verify archive was copied back
8992 mock_copy .assert_any_call ("/tmp/test_dir/native_dependencies.tar.gz" , "payload/archives/native_dependencies.tar.gz" )
9093
9194 @patch ("datacustomcode.deploy.cmd_output" )
9295 @patch ("datacustomcode.deploy.shutil.copy" )
9396 @patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
9497 @patch ("datacustomcode.deploy.os.path.join" )
98+ @patch ("datacustomcode.deploy.os.makedirs" )
9599 def test_prepare_dependency_archive_build_image (
96- self , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
100+ self , mock_makedirs , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
97101 ):
98102 """Test prepare_dependency_archive when Docker image needs to be built."""
99103 # Mock the temporary directory context manager
@@ -124,15 +128,19 @@ def test_prepare_dependency_archive_build_image(
124128 # Verify docker run command was called
125129 mock_cmd_output .assert_any_call (self .EXPECTED_DOCKER_RUN_CMD )
126130
131+ # Verify archives directory was created
132+ mock_makedirs .assert_called_once_with ("payload/archives" , exist_ok = True )
133+
127134 # Verify archive was copied back
128135 mock_copy .assert_any_call ("/tmp/test_dir/native_dependencies.tar.gz" , "payload/archives/native_dependencies.tar.gz" )
129136
130137 @patch ("datacustomcode.deploy.cmd_output" )
131138 @patch ("datacustomcode.deploy.shutil.copy" )
132139 @patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
133140 @patch ("datacustomcode.deploy.os.path.join" )
141+ @patch ("datacustomcode.deploy.os.makedirs" )
134142 def test_prepare_dependency_archive_docker_build_failure (
135- self , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
143+ self , mock_makedirs , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
136144 ):
137145 """Test prepare_dependency_archive when Docker build fails."""
138146 # Mock the temporary directory context manager
@@ -161,8 +169,9 @@ def test_prepare_dependency_archive_docker_build_failure(
161169 @patch ("datacustomcode.deploy.shutil.copy" )
162170 @patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
163171 @patch ("datacustomcode.deploy.os.path.join" )
172+ @patch ("datacustomcode.deploy.os.makedirs" )
164173 def test_prepare_dependency_archive_docker_run_failure (
165- self , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
174+ self , mock_makedirs , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
166175 ):
167176 """Test prepare_dependency_archive when Docker run fails."""
168177 # Mock the temporary directory context manager
@@ -195,8 +204,9 @@ def test_prepare_dependency_archive_docker_run_failure(
195204 @patch ("datacustomcode.deploy.shutil.copy" )
196205 @patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
197206 @patch ("datacustomcode.deploy.os.path.join" )
207+ @patch ("datacustomcode.deploy.os.makedirs" )
198208 def test_prepare_dependency_archive_file_copy_failure (
199- self , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
209+ self , mock_makedirs , mock_join , mock_temp_dir , mock_copy , mock_cmd_output
200210 ):
201211 """Test prepare_dependency_archive when file copy fails."""
202212 # Mock the temporary directory context manager
0 commit comments