@@ -142,11 +142,59 @@ def test_get_patch_dates(self):
142
142
for date in expected_dates :
143
143
assert date in patch_dates
144
144
145
+ @mock_patch ('delphi_nssp.patch.get_source_data' )
146
+ @mock_patch ('delphi_nssp.patch.run_module' )
147
+ @mock_patch ('delphi_nssp.patch.get_structured_logger' )
148
+ @mock_patch ('delphi_nssp.patch.read_params' )
149
+ def test_patch_from_local_source (self , mock_read_params , mock_get_structured_logger , mock_run_module , mock_get_source_data ):
150
+ mock_read_params .return_value = {
151
+ "common" : {
152
+ "log_filename" : "test.log" ,
153
+ "custom_run" : True
154
+ },
155
+ "patch" : {
156
+ "user" : "user" ,
157
+ "start_issue" : "2021-01-01" ,
158
+ "end_issue" : "2021-01-16" ,
159
+ "patch_dir" : "./patch_dir" ,
160
+ "source_dir" : "./source_dir"
161
+ }
162
+ }
163
+ patch ()
164
+
165
+ mock_get_source_data .assert_not_called ()
166
+
167
+ @mock_patch ('delphi_nssp.patch.get_source_data' )
168
+ @mock_patch ('delphi_nssp.patch.rmtree' )
169
+ @mock_patch ('delphi_nssp.patch.run_module' )
170
+ @mock_patch ('delphi_nssp.patch.get_structured_logger' )
171
+ @mock_patch ('delphi_nssp.patch.read_params' )
172
+ def test_patch_download_remote_source (self , mock_read_params , mock_get_structured_logger , mock_run_module , mock_rmtree , mock_get_source_data ):
173
+ mock_read_params .return_value = {
174
+ "common" : {
175
+ "log_filename" : "test.log" ,
176
+ "custom_run" : True
177
+ },
178
+ "patch" : {
179
+ "user" : "user" ,
180
+ "start_issue" : "2021-01-01" ,
181
+ "end_issue" : "2021-01-16" ,
182
+ "patch_dir" : "./patch_dir" ,
183
+ "source_dir" : "./does_not_exist"
184
+ }
185
+ }
186
+ patch ()
187
+ mock_get_source_data .assert_called_once ()
188
+ assert mock_rmtree .call_count == 1
189
+ shutil .rmtree (mock_read_params .return_value ["patch" ]["patch_dir" ])
190
+
191
+
145
192
193
+ @mock_patch ('delphi_nssp.patch.get_source_data' )
146
194
@mock_patch ('delphi_nssp.patch.run_module' )
147
195
@mock_patch ('delphi_nssp.patch.get_structured_logger' )
148
196
@mock_patch ('delphi_nssp.patch.read_params' )
149
- def test_patch_confirm_dir_structure_created (self , mock_read_params , mock_get_structured_logger , mock_run_module ):
197
+ def test_patch_confirm_dir_structure_created (self , mock_read_params , mock_get_structured_logger , mock_run_module , mock_get_source_data ):
150
198
mock_read_params .return_value = {
151
199
"common" : {
152
200
"log_filename" : "test.log" ,
@@ -180,7 +228,7 @@ def test_patch_confirm_dir_structure_created(self, mock_read_params, mock_get_st
180
228
181
229
@mock_patch ('delphi_nssp.patch.get_structured_logger' )
182
230
@mock_patch ('delphi_nssp.patch.read_params' )
183
- def test_patch_confirm_values_generated (self , mock_read_params , mock_get_structured_logger ):
231
+ def test_full_patch_code (self , mock_read_params , mock_get_structured_logger ):
184
232
mock_get_structured_logger .return_value .name = "delphi_nssp.patch"
185
233
mock_read_params .return_value = {
186
234
"common" : {
0 commit comments