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 852509c96d983e595fa082e13b771a7f89771803
This commit is contained in:
parent
93e161b2c6
commit
b297c67765
|
@ -57,10 +57,10 @@ def in_draft_expire_freeze(when=None):
|
|||
d = Meeting.get_second_cut_off()
|
||||
# for some reason, the old Perl code started at 9 am
|
||||
second_cut_off = datetime.datetime.combine(d, datetime.time(9, 0))
|
||||
|
||||
|
||||
d = Meeting.get_ietf_monday()
|
||||
ietf_monday = datetime.datetime.combine(d, datetime.time(0, 0))
|
||||
|
||||
|
||||
return second_cut_off <= when < ietf_monday
|
||||
|
||||
def send_expire_warning_for_draft(doc):
|
||||
|
@ -76,7 +76,7 @@ def send_expire_warning_for_draft(doc):
|
|||
|
||||
s = doc.get_state("draft-iesg")
|
||||
state = s.name if s else "I-D Exists"
|
||||
|
||||
|
||||
frm = None
|
||||
request = None
|
||||
if to or cc:
|
||||
|
@ -151,7 +151,7 @@ def clean_up_draft_files():
|
|||
pattern = os.path.join(settings.INTERNET_DRAFT_PATH, "draft-*.*")
|
||||
files = []
|
||||
filename_re = re.compile('^(.*)-(\d\d)$')
|
||||
|
||||
|
||||
def splitext(fn):
|
||||
"""
|
||||
Split the pathname path into a pair (root, ext) such that root + ext
|
||||
|
@ -182,23 +182,16 @@ def clean_up_draft_files():
|
|||
def move_file_to(subdir):
|
||||
shutil.move(path,
|
||||
os.path.join(settings.INTERNET_DRAFT_ARCHIVE_DIR, subdir, basename))
|
||||
|
||||
|
||||
try:
|
||||
doc = Document.objects.get(name=filename, rev=revision)
|
||||
|
||||
state = doc.get_state_slug()
|
||||
|
||||
if state == "rfc":
|
||||
if ext != ".txt":
|
||||
move_file_to("unknown_ids")
|
||||
elif state in ("expired", "repl", "auth-rm", "ietf-rm") and doc.expires and doc.expires.date() < cut_off:
|
||||
# Expired, Replaced, Withdrawn by Author/IETF, and expired
|
||||
if os.path.getsize(path) < 1500:
|
||||
# we don't make tombstones any more so this should
|
||||
# go away in the future
|
||||
move_file_to("deleted_tombstones")
|
||||
else:
|
||||
move_file_to("expired_without_tombstone")
|
||||
|
||||
if state in ("rfc","repl"):
|
||||
move_file_to("")
|
||||
elif state in ("expired", "auth-rm", "ietf-rm") and doc.expires and doc.expires.date() < cut_off:
|
||||
move_file_to("")
|
||||
|
||||
except Document.DoesNotExist:
|
||||
move_file_to("unknown_ids")
|
||||
|
|
|
@ -567,12 +567,11 @@ class ExpireIDsTests(TestCase):
|
|||
|
||||
clean_up_draft_files()
|
||||
|
||||
# txt files shouldn't be moved (for some reason)
|
||||
self.assertTrue(os.path.exists(os.path.join(self.id_dir, txt)))
|
||||
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, pdf)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "unknown_ids", pdf)))
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt)))
|
||||
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, pdf)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, pdf)))
|
||||
|
||||
# expire draft
|
||||
draft.set_state(State.objects.get(used=True, type="draft", slug="expired"))
|
||||
|
@ -587,26 +586,13 @@ class ExpireIDsTests(TestCase):
|
|||
e.time = draft.expires
|
||||
e.save()
|
||||
|
||||
# expired without tombstone
|
||||
txt = "%s-%s.txt" % (draft.name, draft.rev)
|
||||
self.write_draft_file(txt, 5000)
|
||||
|
||||
clean_up_draft_files()
|
||||
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "expired_without_tombstone", txt)))
|
||||
|
||||
|
||||
# expired with tombstone
|
||||
revision_before = draft.rev
|
||||
|
||||
txt = "%s-%s.txt" % (draft.name, draft.rev)
|
||||
self.write_draft_file(txt, 1000) # < 1500 means tombstone
|
||||
|
||||
clean_up_draft_files()
|
||||
|
||||
self.assertTrue(not os.path.exists(os.path.join(self.id_dir, txt)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, "deleted_tombstones", txt)))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.archive_dir, txt)))
|
||||
|
||||
|
||||
class ExpireLastCallTests(TestCase):
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
# --- Add entries at the top ---
|
||||
|
||||
personal/rcross/v5.0.2@7398
|
||||
personal/rcross/v5.0.2@7378
|
||||
personal/jmh/v5.0.2@7375
|
||||
personal/rjs/v4.90@7138 Was waiting for additional tests
|
||||
|
|
Loading…
Reference in a new issue