|
9 | 9 | from django.utils import timezone
|
10 | 10 | from cradmin_legacy import cradmin_testhelpers
|
11 | 11 | from model_bakery import baker
|
| 12 | +from cradmin_legacy.apps.cradmin_temporaryfileuploadstore.models import TemporaryFileCollection |
12 | 13 |
|
13 | 14 | from devilry.apps.core import models as core_models
|
14 | 15 | from devilry.devilry_account.models import PeriodUserGuidelineAcceptance
|
@@ -1175,8 +1176,35 @@ def test_upload_single_file(self):
|
1175 | 1176 | }
|
1176 | 1177 | })
|
1177 | 1178 | self.assertEqual(1, group_models.GroupComment.objects.count())
|
| 1179 | + self.assertEqual(1, TemporaryFileCollection.objects.count()) |
1178 | 1180 | self.assertEqual(1, comment_models.CommentFile.objects.count())
|
1179 | 1181 |
|
| 1182 | + def test_upload_has_temporary_file_collection_id_but_empty_collection(self): |
| 1183 | + # Test that a CommentFile is created on upload. |
| 1184 | + feedbackset = group_baker.feedbackset_first_attempt_unpublished( |
| 1185 | + group__parentnode__parentnode=baker.make_recipe('devilry.apps.core.period_active')) |
| 1186 | + candidate = baker.make('core.Candidate', assignment_group=feedbackset.group) |
| 1187 | + temporary_filecollection = baker.make( |
| 1188 | + 'cradmin_temporaryfileuploadstore.TemporaryFileCollection', |
| 1189 | + user=candidate.relatedstudent.user) |
| 1190 | + mockresponse = self.mock_http200_postrequest_htmls( |
| 1191 | + cradmin_role=candidate.assignment_group, |
| 1192 | + requestuser=candidate.relatedstudent.user, |
| 1193 | + viewkwargs={'pk': feedbackset.group.id}, |
| 1194 | + requestkwargs={ |
| 1195 | + 'data': { |
| 1196 | + 'text': '', |
| 1197 | + 'student_add_comment': 'unused value', |
| 1198 | + 'temporary_file_collection_id': temporary_filecollection.id |
| 1199 | + } |
| 1200 | + }) |
| 1201 | + self.assertEqual( |
| 1202 | + 'A comment must have either text or a file attached, or both. An empty comment is not allowed.', |
| 1203 | + mockresponse.selector.one('#error_1_id_text').alltext_normalized) |
| 1204 | + self.assertEqual(0, group_models.GroupComment.objects.count()) |
| 1205 | + self.assertEqual(1, TemporaryFileCollection.objects.count()) |
| 1206 | + self.assertEqual(1, group_models.FeedbackSet.objects.count()) |
| 1207 | + |
1180 | 1208 | def test_upload_single_file_content(self):
|
1181 | 1209 | # Test the content of a CommentFile after upload.
|
1182 | 1210 | feedbackset = group_baker.feedbackset_first_attempt_unpublished(
|
|
0 commit comments