Skip to content

Commit b297c67

Browse files
committed
Merged [7396] from rcross@amsl.com: updated test for clean_up_draft_files.
- Legacy-Id: 7401 Note: SVN reference [7396] has been migrated to Git commit 852509c
1 parent 93e161b commit b297c67

3 files changed

Lines changed: 16 additions & 36 deletions

File tree

ietf/doc/expire.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def in_draft_expire_freeze(when=None):
5757
d = Meeting.get_second_cut_off()
5858
# for some reason, the old Perl code started at 9 am
5959
second_cut_off = datetime.datetime.combine(d, datetime.time(9, 0))
60-
60+
6161
d = Meeting.get_ietf_monday()
6262
ietf_monday = datetime.datetime.combine(d, datetime.time(0, 0))
63-
63+
6464
return second_cut_off <= when < ietf_monday
6565

6666
def send_expire_warning_for_draft(doc):
@@ -76,7 +76,7 @@ def send_expire_warning_for_draft(doc):
7676

7777
s = doc.get_state("draft-iesg")
7878
state = s.name if s else "I-D Exists"
79-
79+
8080
frm = None
8181
request = None
8282
if to or cc:
@@ -151,7 +151,7 @@ def clean_up_draft_files():
151151
pattern = os.path.join(settings.INTERNET_DRAFT_PATH, "draft-*.*")
152152
files = []
153153
filename_re = re.compile('^(.*)-(\d\d)$')
154-
154+
155155
def splitext(fn):
156156
"""
157157
Split the pathname path into a pair (root, ext) such that root + ext
@@ -182,23 +182,16 @@ def splitext(fn):
182182
def move_file_to(subdir):
183183
shutil.move(path,
184184
os.path.join(settings.INTERNET_DRAFT_ARCHIVE_DIR, subdir, basename))
185-
185+
186186
try:
187187
doc = Document.objects.get(name=filename, rev=revision)
188188

189189
state = doc.get_state_slug()
190190

191-
if state == "rfc":
192-
if ext != ".txt":
193-
move_file_to("unknown_ids")
194-
elif state in ("expired", "repl", "auth-rm", "ietf-rm") and doc.expires and doc.expires.date() < cut_off:
195-
# Expired, Replaced, Withdrawn by Author/IETF, and expired
196-
if os.path.getsize(path) < 1500:
197-
# we don't make tombstones any more so this should
198-
# go away in the future
199-
move_file_to("deleted_tombstones")
200-
else:
201-
move_file_to("expired_without_tombstone")
202-
191+
if state in ("rfc","repl"):
192+
move_file_to("")
193+
elif state in ("expired", "auth-rm", "ietf-rm") and doc.expires and doc.expires.date() < cut_off:
194+
move_file_to("")
195+
203196
except Document.DoesNotExist:
204197
move_file_to("unknown_ids")

ietf/doc/tests_draft.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,11 @@ def test_clean_up_draft_files(self):
567567

568568
clean_up_draft_files()
569569

570-
# txt files shouldn't be moved (for some reason)
571-
self.assertTrue(os.path.exists(os.path.join(self.id_dir, txt)))
572-
573-
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, pdf)))
574-
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "unknown_ids", pdf)))
570+
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
571+
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt)))
575572

573+
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, pdf)))
574+
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, pdf)))
576575

577576
# expire draft
578577
draft.set_state(State.objects.get(used=True, type="draft", slug="expired"))
@@ -587,26 +586,13 @@ def test_clean_up_draft_files(self):
587586
e.time = draft.expires
588587
e.save()
589588

590-
# expired without tombstone
591589
txt = "%s-%s.txt" % (draft.name, draft.rev)
592590
self.write_draft_file(txt, 5000)
593591

594592
clean_up_draft_files()
595593

596594
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
597-
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "expired_without_tombstone", txt)))
598-
599-
600-
# expired with tombstone
601-
revision_before = draft.rev
602-
603-
txt = "%s-%s.txt" % (draft.name, draft.rev)
604-
self.write_draft_file(txt, 1000) # < 1500 means tombstone
605-
606-
clean_up_draft_files()
607-
608-
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
609-
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "deleted_tombstones", txt)))
595+
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt)))
610596

611597

612598
class ExpireLastCallTests(TestCase):

ready-for-merge

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# --- Add entries at the top ---
99

10+
personal/rcross/v5.0.2@7398
1011
personal/rcross/v5.0.2@7378
1112
personal/jmh/v5.0.2@7375
1213
personal/rjs/v4.90@7138 Was waiting for additional tests

0 commit comments

Comments
 (0)