Move draft files to archive when setting the draft state to RFC,
fixes #1254. - Legacy-Id: 7157
This commit is contained in:
parent
4525c22b54
commit
32874a2c89
|
@ -10,6 +10,7 @@ from ietf.doc.models import *
|
|||
from ietf.person.models import *
|
||||
from ietf.name.models import *
|
||||
from ietf.doc.utils import add_state_change_event
|
||||
from ietf.doc.expire import move_draft_files_to_archive
|
||||
|
||||
#QUEUE_URL = "http://www.rfc-editor.org/queue2.xml"
|
||||
#INDEX_URL = "http://www.rfc-editor.org/rfc/rfc-index.xml"
|
||||
|
@ -363,6 +364,7 @@ def update_docs_from_rfc_index(data, skip_older_than_date=None):
|
|||
|
||||
if doc.get_state_slug() != "rfc":
|
||||
changed_states.append(State.objects.get(used=True, type="draft", slug="rfc"))
|
||||
move_draft_files_to_archive(doc, doc.rev)
|
||||
|
||||
if doc.stream != stream_mapping[stream]:
|
||||
changed_attributes["stream"] = stream_mapping[stream]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import unittest, re, json, datetime, StringIO
|
||||
import unittest, re, json, datetime, StringIO, shutil
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse as urlreverse
|
||||
|
||||
|
@ -185,6 +186,24 @@ ICANN
|
|||
|
||||
|
||||
class RFCSyncTests(TestCase):
|
||||
def setUp(self):
|
||||
self.id_dir = os.path.abspath("tmp-id-dir")
|
||||
self.archive_dir = os.path.abspath("tmp-id-archive")
|
||||
if not os.path.exists(self.id_dir):
|
||||
os.mkdir(self.id_dir)
|
||||
if not os.path.exists(self.archive_dir):
|
||||
os.mkdir(self.archive_dir)
|
||||
settings.INTERNET_DRAFT_PATH = self.id_dir
|
||||
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.archive_dir
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.id_dir)
|
||||
shutil.rmtree(self.archive_dir)
|
||||
|
||||
def write_draft_file(self, name, size):
|
||||
with open(os.path.join(self.id_dir, name), 'w') as f:
|
||||
f.write("a" * size)
|
||||
|
||||
def test_rfc_index(self):
|
||||
doc = make_test_data()
|
||||
doc.set_state(State.objects.get(used=True, type="draft-iesg", slug="rfcqueue"))
|
||||
|
@ -285,6 +304,8 @@ class RFCSyncTests(TestCase):
|
|||
|
||||
|
||||
mailbox_before = len(outbox)
|
||||
draft_filename = "%s-%s.txt" % (doc.name, doc.rev)
|
||||
self.write_draft_file(draft_filename, 5000)
|
||||
|
||||
changed = rfceditor.update_docs_from_rfc_index(data, today - datetime.timedelta(days=30))
|
||||
|
||||
|
@ -305,6 +326,8 @@ class RFCSyncTests(TestCase):
|
|||
self.assertEqual(doc.get_state_slug("draft-stream-ise"), "pub")
|
||||
self.assertEqual(doc.std_level_id, "ps")
|
||||
self.assertEqual(doc.pages, 42)
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, draft_filename)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, draft_filename)))
|
||||
|
||||
# make sure we can apply it again with no changes
|
||||
changed = rfceditor.update_docs_from_rfc_index(data, today - datetime.timedelta(days=30))
|
||||
|
|
Loading…
Reference in a new issue