@@ -46,16 +46,16 @@ class TestPrepareDependencyArchive:
46
46
EXPECTED_DOCKER_RUN_CMD = (
47
47
"DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm "
48
48
"-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"
51
50
)
52
51
53
52
@patch ("datacustomcode.deploy.cmd_output" )
54
53
@patch ("datacustomcode.deploy.shutil.copy" )
55
54
@patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
56
55
@patch ("datacustomcode.deploy.os.path.join" )
56
+ @patch ("datacustomcode.deploy.os.makedirs" )
57
57
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
59
59
):
60
60
"""Test prepare_dependency_archive when Docker image already exists."""
61
61
# Mock the temporary directory context manager
@@ -85,15 +85,19 @@ def test_prepare_dependency_archive_image_exists(
85
85
# Verify docker run command was called
86
86
mock_cmd_output .assert_any_call (self .EXPECTED_DOCKER_RUN_CMD )
87
87
88
+ # Verify archives directory was created
89
+ mock_makedirs .assert_called_once_with ("payload/archives" , exist_ok = True )
90
+
88
91
# Verify archive was copied back
89
92
mock_copy .assert_any_call ("/tmp/test_dir/native_dependencies.tar.gz" , "payload/archives/native_dependencies.tar.gz" )
90
93
91
94
@patch ("datacustomcode.deploy.cmd_output" )
92
95
@patch ("datacustomcode.deploy.shutil.copy" )
93
96
@patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
94
97
@patch ("datacustomcode.deploy.os.path.join" )
98
+ @patch ("datacustomcode.deploy.os.makedirs" )
95
99
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
97
101
):
98
102
"""Test prepare_dependency_archive when Docker image needs to be built."""
99
103
# Mock the temporary directory context manager
@@ -124,15 +128,19 @@ def test_prepare_dependency_archive_build_image(
124
128
# Verify docker run command was called
125
129
mock_cmd_output .assert_any_call (self .EXPECTED_DOCKER_RUN_CMD )
126
130
131
+ # Verify archives directory was created
132
+ mock_makedirs .assert_called_once_with ("payload/archives" , exist_ok = True )
133
+
127
134
# Verify archive was copied back
128
135
mock_copy .assert_any_call ("/tmp/test_dir/native_dependencies.tar.gz" , "payload/archives/native_dependencies.tar.gz" )
129
136
130
137
@patch ("datacustomcode.deploy.cmd_output" )
131
138
@patch ("datacustomcode.deploy.shutil.copy" )
132
139
@patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
133
140
@patch ("datacustomcode.deploy.os.path.join" )
141
+ @patch ("datacustomcode.deploy.os.makedirs" )
134
142
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
136
144
):
137
145
"""Test prepare_dependency_archive when Docker build fails."""
138
146
# Mock the temporary directory context manager
@@ -161,8 +169,9 @@ def test_prepare_dependency_archive_docker_build_failure(
161
169
@patch ("datacustomcode.deploy.shutil.copy" )
162
170
@patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
163
171
@patch ("datacustomcode.deploy.os.path.join" )
172
+ @patch ("datacustomcode.deploy.os.makedirs" )
164
173
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
166
175
):
167
176
"""Test prepare_dependency_archive when Docker run fails."""
168
177
# Mock the temporary directory context manager
@@ -195,8 +204,9 @@ def test_prepare_dependency_archive_docker_run_failure(
195
204
@patch ("datacustomcode.deploy.shutil.copy" )
196
205
@patch ("datacustomcode.deploy.tempfile.TemporaryDirectory" )
197
206
@patch ("datacustomcode.deploy.os.path.join" )
207
+ @patch ("datacustomcode.deploy.os.makedirs" )
198
208
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
200
210
):
201
211
"""Test prepare_dependency_archive when file copy fails."""
202
212
# Mock the temporary directory context manager
0 commit comments