@@ -1063,8 +1063,8 @@ def test_resend_upload_button_scenarios(self):
10631063 {
10641064 "milestone" : Milestones .UPLOAD_COMPLETE .value ,
10651065 },
1066- None ,
1067- str ,
1066+ [ "🔄 Resend" , 'class="button"' , "onclick=" ] ,
1067+ SafeString ,
10681068 "successful upload" ,
10691069 ),
10701070 ]
@@ -1079,16 +1079,13 @@ def test_resend_upload_button_scenarios(self):
10791079 breadcrumb = UploadBreadcrumbFactory (breadcrumb_data = breadcrumb_data )
10801080 result = self .admin .resend_upload_button (breadcrumb )
10811081
1082- if expected_contains is None :
1083- self .assertEqual (result , "-" , f"Failed for: { description } " )
1084- else :
1085- self .assertIsInstance (
1086- result , expected_type , f"Failed for: { description } "
1082+ self .assertIsInstance (
1083+ result , expected_type , f"Failed for: { description } "
1084+ )
1085+ for expected_content in expected_contains :
1086+ self .assertIn (
1087+ expected_content , result , f"Failed for: { description } "
10871088 )
1088- for expected_content in expected_contains :
1089- self .assertIn (
1090- expected_content , result , f"Failed for: { description } "
1091- )
10921089
10931090 def test_resend_upload_action_scenarios (self ):
10941091 """Test resend_upload_action with various scenarios."""
@@ -1120,10 +1117,7 @@ def test_resend_upload_action_scenarios(self):
11201117 },
11211118 "abcdef1234567890" ,
11221119 True ,
1123- [
1124- "✅ This upload does not appear to have failed" ,
1125- "Resend option is not available" ,
1126- ],
1120+ ["🔄 Resend Upload" , 'class="button default"' , "abcdef1" , "⚠️ Note:" ],
11271121 "successful upload" ,
11281122 ),
11291123 ({}, "abcdef1234567890" , False , None , "new object without pk" ),
@@ -1170,22 +1164,27 @@ def test_resend_upload_view_with_nonexistent_breadcrumb(self, mock_messages_erro
11701164 request , "Upload breadcrumb not found."
11711165 )
11721166
1173- @patch ("django.contrib.messages.error " )
1174- def test_resend_upload_view_with_non_failed_upload (self , mock_messages_error ):
1175- """Test resend_upload_view handles non-failed uploads."""
1167+ @patch ("django.contrib.messages.success " )
1168+ def test_resend_upload_view_with_non_failed_upload (self , mock_messages_success ):
1169+ """Test resend_upload_view allows resending non-failed uploads."""
11761170 breadcrumb_data = {
11771171 "milestone" : Milestones .UPLOAD_COMPLETE .value ,
11781172 }
1179- breadcrumb = UploadBreadcrumbFactory (breadcrumb_data = breadcrumb_data )
1173+ breadcrumb = UploadBreadcrumbFactory (
1174+ breadcrumb_data = breadcrumb_data , commit_sha = "abcdef1234567890"
1175+ )
11801176 request = MagicMock ()
11811177 request .user = self .user
11821178
1183- with patch .object (self .admin , "get_object" , return_value = breadcrumb ):
1179+ with (
1180+ patch .object (self .admin , "get_object" , return_value = breadcrumb ),
1181+ patch .object (self .admin , "_resend_upload" , return_value = (True , None )),
1182+ ):
11841183 response = self .admin .resend_upload_view (request , str (breadcrumb .id ))
11851184
1186- mock_messages_error . assert_called_once_with (
1187- request , "This upload does not appear to have failed."
1188- )
1185+ mock_messages_success . assert_called_once ()
1186+ success_message = mock_messages_success . call_args [ 0 ][ 1 ]
1187+ self . assertIn ( "Upload resend triggered successfully" , success_message )
11891188
11901189 @patch ("django.contrib.messages.success" )
11911190 def test_resend_upload_view_successful_resend (self , mock_messages_success ):
0 commit comments