chore: Merge in fixes that were coattailing fixups4
This commit is contained in:
commit
3e57b9e82a
|
@ -707,7 +707,7 @@ class SubmissionAutoUploadForm(SubmissionBaseUploadForm):
|
|||
elif alias.document.get_state_slug() == "rfc":
|
||||
self.add_error(
|
||||
'replaces',
|
||||
forms.ValidationError("An Internet-Draft cannot replace an RFC"),
|
||||
forms.ValidationError("An Internet-Draft cannot replace another Internet-Draft that has become an RFC"),
|
||||
)
|
||||
elif alias.document.get_state_slug('draft-iesg') in ('approved', 'ann', 'rfcqueue'):
|
||||
self.add_error(
|
||||
|
|
|
@ -3099,13 +3099,15 @@ class SubmissionUploadFormTests(BaseSubmitTestCase):
|
|||
|
||||
# can't replace RFC
|
||||
rfc = WgRfcFactory()
|
||||
draft = WgDraftFactory(states=[("draft", "rfc")])
|
||||
draft.relateddocument_set.create(relationship_id="became_rfc", target=rfc.docalias.first())
|
||||
form = SubmissionAutoUploadForm(
|
||||
request_factory.get('/some/url'),
|
||||
data={'user': auth.user.username, 'replaces': rfc.name},
|
||||
data={'user': auth.user.username, 'replaces': draft.name},
|
||||
files=files_dict,
|
||||
)
|
||||
self.assertFalse(form.is_valid())
|
||||
self.assertIn('An Internet-Draft cannot replace an RFC', form.errors['replaces'])
|
||||
self.assertIn('An Internet-Draft cannot replace another Internet-Draft that has become an RFC', form.errors['replaces'])
|
||||
|
||||
# can't replace draft approved by iesg
|
||||
existing_drafts[0].set_state(State.objects.get(type='draft-iesg', slug='approved'))
|
||||
|
@ -3697,25 +3699,9 @@ class RefsTests(BaseSubmitTestCase):
|
|||
|
||||
|
||||
class PostSubmissionTests(BaseSubmitTestCase):
|
||||
@override_settings(RFC_FILE_TYPES=('txt', 'xml'), IDSUBMIT_FILE_TYPES=('pdf', 'md'))
|
||||
def test_find_submission_filenames_rfc(self):
|
||||
"""Posting an RFC submission should use RFC_FILE_TYPES"""
|
||||
rfc = IndividualRfcFactory()
|
||||
path = Path(self.staging_dir)
|
||||
for ext in ['txt', 'xml', 'pdf', 'md']:
|
||||
(path / f'{rfc.name}-{rfc.rev}.{ext}').touch()
|
||||
files = find_submission_filenames(rfc)
|
||||
self.assertCountEqual(
|
||||
files,
|
||||
{
|
||||
'txt': f'{path}/{rfc.name}-{rfc.rev}.txt',
|
||||
'xml': f'{path}/{rfc.name}-{rfc.rev}.xml',
|
||||
# should NOT find the pdf or md
|
||||
}
|
||||
)
|
||||
|
||||
@override_settings(RFC_FILE_TYPES=('txt', 'xml'), IDSUBMIT_FILE_TYPES=('pdf', 'md'))
|
||||
def test_find_submission_filenames_draft(self):
|
||||
def test_find_submission_filenames(self):
|
||||
"""Posting an I-D submission should use IDSUBMIT_FILE_TYPES"""
|
||||
draft = WgDraftFactory()
|
||||
path = Path(self.staging_dir)
|
||||
|
|
|
@ -287,7 +287,7 @@ def find_submission_filenames(draft):
|
|||
"""
|
||||
path = pathlib.Path(settings.IDSUBMIT_STAGING_PATH)
|
||||
stem = f'{draft.name}-{draft.rev}'
|
||||
allowed_types = settings.RFC_FILE_TYPES if draft.get_state_slug() == 'rfc' else settings.IDSUBMIT_FILE_TYPES
|
||||
allowed_types = settings.IDSUBMIT_FILE_TYPES
|
||||
candidates = {ext: path / f'{stem}.{ext}' for ext in allowed_types}
|
||||
return {ext: str(filename) for ext, filename in candidates.items() if filename.exists()}
|
||||
|
||||
|
|
Loading…
Reference in a new issue