Skip to content

Commit 32874a2

Browse files
committed
Move draft files to archive when setting the draft state to RFC,
fixes ietf-tools#1254. - Legacy-Id: 7157
1 parent 4525c22 commit 32874a2

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

ietf/sync/rfceditor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ietf.person.models import *
1111
from ietf.name.models import *
1212
from ietf.doc.utils import add_state_change_event
13+
from ietf.doc.expire import move_draft_files_to_archive
1314

1415
#QUEUE_URL = "http://www.rfc-editor.org/queue2.xml"
1516
#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):
363364

364365
if doc.get_state_slug() != "rfc":
365366
changed_states.append(State.objects.get(used=True, type="draft", slug="rfc"))
367+
move_draft_files_to_archive(doc, doc.rev)
366368

367369
if doc.stream != stream_mapping[stream]:
368370
changed_attributes["stream"] = stream_mapping[stream]

ietf/sync/tests.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import unittest, re, json, datetime, StringIO
1+
import unittest, re, json, datetime, StringIO, shutil
2+
23
from django.conf import settings
34
from django.core.urlresolvers import reverse as urlreverse
45

@@ -185,6 +186,24 @@ def test_notify_page(self):
185186

186187

187188
class RFCSyncTests(TestCase):
189+
def setUp(self):
190+
self.id_dir = os.path.abspath("tmp-id-dir")
191+
self.archive_dir = os.path.abspath("tmp-id-archive")
192+
if not os.path.exists(self.id_dir):
193+
os.mkdir(self.id_dir)
194+
if not os.path.exists(self.archive_dir):
195+
os.mkdir(self.archive_dir)
196+
settings.INTERNET_DRAFT_PATH = self.id_dir
197+
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.archive_dir
198+
199+
def tearDown(self):
200+
shutil.rmtree(self.id_dir)
201+
shutil.rmtree(self.archive_dir)
202+
203+
def write_draft_file(self, name, size):
204+
with open(os.path.join(self.id_dir, name), 'w') as f:
205+
f.write("a" * size)
206+
188207
def test_rfc_index(self):
189208
doc = make_test_data()
190209
doc.set_state(State.objects.get(used=True, type="draft-iesg", slug="rfcqueue"))
@@ -285,6 +304,8 @@ def test_rfc_index(self):
285304

286305

287306
mailbox_before = len(outbox)
307+
draft_filename = "%s-%s.txt" % (doc.name, doc.rev)
308+
self.write_draft_file(draft_filename, 5000)
288309

289310
changed = rfceditor.update_docs_from_rfc_index(data, today - datetime.timedelta(days=30))
290311

@@ -305,6 +326,8 @@ def test_rfc_index(self):
305326
self.assertEqual(doc.get_state_slug("draft-stream-ise"), "pub")
306327
self.assertEqual(doc.std_level_id, "ps")
307328
self.assertEqual(doc.pages, 42)
329+
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, draft_filename)))
330+
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, draft_filename)))
308331

309332
# make sure we can apply it again with no changes
310333
changed = rfceditor.update_docs_from_rfc_index(data, today - datetime.timedelta(days=30))

0 commit comments

Comments
 (0)