Skip to content

Commit 8b7fa11

Browse files
authored
chore: remove single-use repair_dead_on_expire task (#8348)
* chore: remove single-use repair_dead_on_expire task * fix: remove repair_dead_on_expire * chore: remove abandoned imports
1 parent 8cadc69 commit 8b7fa11

File tree

4 files changed

+6
-126
lines changed

4 files changed

+6
-126
lines changed

ietf/doc/expire.py

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
from typing import List, Optional # pyflakes:ignore
1515

16-
from ietf.doc.utils import new_state_change_event, update_action_holders
16+
from ietf.doc.utils import update_action_holders
1717
from ietf.utils import log
1818
from ietf.utils.mail import send_mail
19-
from ietf.doc.models import Document, DocEvent, State, StateDocEvent
19+
from ietf.doc.models import Document, DocEvent, State
2020
from ietf.person.models import Person
2121
from ietf.meeting.models import Meeting
2222
from ietf.mailtrigger.utils import gather_address_lists
@@ -235,41 +235,3 @@ def move_file_to(subdir):
235235
# All uses of this past 2014 seem related to major system failures.
236236
move_file_to("unknown_ids")
237237

238-
239-
def repair_dead_on_expire():
240-
by = Person.objects.get(name="(System)")
241-
id_exists = State.objects.get(type="draft-iesg", slug="idexists")
242-
dead = State.objects.get(type="draft-iesg", slug="dead")
243-
dead_drafts = Document.objects.filter(
244-
states__type="draft-iesg", states__slug="dead", type_id="draft"
245-
)
246-
for d in dead_drafts:
247-
dead_event = d.latest_event(
248-
StateDocEvent, state_type="draft-iesg", state__slug="dead"
249-
)
250-
if dead_event is not None:
251-
if d.docevent_set.filter(type="expired_document").exists():
252-
closest_expiry = min(
253-
[
254-
abs(e.time - dead_event.time)
255-
for e in d.docevent_set.filter(type="expired_document")
256-
]
257-
)
258-
if closest_expiry.total_seconds() < 60:
259-
d.set_state(id_exists)
260-
events = []
261-
e = DocEvent(
262-
doc=d,
263-
rev=d.rev,
264-
type="added_comment",
265-
by=by,
266-
desc="IESG Dead state was set due only to document expiry - changing IESG state to ID-Exists",
267-
)
268-
e.skip_community_list_notification = True
269-
e.save()
270-
events.append(e)
271-
e = new_state_change_event(d, by, dead, id_exists)
272-
e.skip_community_list_notification = True
273-
e.save()
274-
events.append(e)
275-
d.save_with_history(events)

ietf/doc/tasks.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
in_draft_expire_freeze,
1919
get_expired_drafts,
2020
expirable_drafts,
21-
repair_dead_on_expire,
2221
send_expire_notice_for_draft,
2322
expire_draft,
2423
clean_up_draft_files,
@@ -62,11 +61,6 @@ def expire_ids_task():
6261
raise
6362

6463

65-
@shared_task
66-
def repair_dead_on_expire_task():
67-
repair_dead_on_expire()
68-
69-
7064
@shared_task
7165
def notify_expirations_task(notify_days=14):
7266
for doc in get_soon_to_expire_drafts(notify_days):

ietf/doc/tests_draft.py

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
import debug # pyflakes:ignore
2121

22-
from ietf.doc.expire import expirable_drafts, get_expired_drafts, repair_dead_on_expire, send_expire_notice_for_draft, expire_draft
23-
from ietf.doc.factories import EditorialDraftFactory, IndividualDraftFactory, StateDocEventFactory, WgDraftFactory, RgDraftFactory, DocEventFactory
22+
from ietf.doc.expire import expirable_drafts, get_expired_drafts, send_expire_notice_for_draft, expire_draft
23+
from ietf.doc.factories import EditorialDraftFactory, IndividualDraftFactory, WgDraftFactory, RgDraftFactory, DocEventFactory
2424
from ietf.doc.models import ( Document, DocReminder, DocEvent,
25-
ConsensusDocEvent, LastCallDocEvent, RelatedDocument, State, StateDocEvent, TelechatDocEvent,
25+
ConsensusDocEvent, LastCallDocEvent, RelatedDocument, State, TelechatDocEvent,
2626
WriteupDocEvent, DocRelationshipName, IanaExpertDocEvent )
2727
from ietf.doc.utils import get_tags_for_stream_id, create_ballot_if_not_open
2828
from ietf.doc.views_draft import AdoptDraftForm
@@ -36,7 +36,7 @@
3636
from ietf.utils.test_utils import login_testing_unauthorized
3737
from ietf.utils.mail import outbox, empty_outbox, get_payload_text
3838
from ietf.utils.test_utils import TestCase
39-
from ietf.utils.timezone import date_today, datetime_today, datetime_from_date, DEADLINE_TZINFO
39+
from ietf.utils.timezone import date_today, datetime_from_date, DEADLINE_TZINFO
4040

4141

4242
class ChangeStateTests(TestCase):
@@ -845,77 +845,6 @@ def test_clean_up_draft_files(self):
845845
self.assertTrue(not os.path.exists(os.path.join(settings.INTERNET_DRAFT_PATH, txt)))
846846
self.assertTrue(os.path.exists(os.path.join(settings.INTERNET_DRAFT_ARCHIVE_DIR, txt)))
847847

848-
@mock.patch("ietf.community.signals.notify_of_event")
849-
def test_repair_dead_on_expire(self, mock_notify):
850-
851-
# Create a draft in iesg idexists - ensure it doesn't get new docevents.
852-
# Create a draft in iesg dead with no expires within the window - ensure it doesn't get new docevents and its state doesn't change.
853-
# Create a draft in iesg dead with an expiry in the window - ensure it gets the right doc events, iesg state changes, draft state doesn't change.
854-
last_year = datetime_today() - datetime.timedelta(days=365)
855-
856-
not_dead = WgDraftFactory(name="draft-not-dead")
857-
not_dead_event_count = not_dead.docevent_set.count()
858-
859-
dead_not_from_expires = WgDraftFactory(name="draft-dead-not-from-expiring")
860-
dead_not_from_expires.set_state(
861-
State.objects.get(type="draft-iesg", slug="dead")
862-
)
863-
StateDocEventFactory(
864-
doc=dead_not_from_expires, state=("draft-iesg", "dead"), time=last_year
865-
)
866-
DocEventFactory(
867-
doc=dead_not_from_expires,
868-
type="expired_document",
869-
time=last_year + datetime.timedelta(days=1),
870-
)
871-
dead_not_from_expires_event_count = dead_not_from_expires.docevent_set.count()
872-
873-
dead_from_expires = []
874-
dead_from_expires_event_count = dict()
875-
for delta in [-5, 5]:
876-
d = WgDraftFactory(
877-
name=f"draft-dead-from-expiring-just-{'before' if delta<0 else 'after'}"
878-
)
879-
d.set_state(State.objects.get(type="draft-iesg", slug="dead"))
880-
StateDocEventFactory(doc=d, state=("draft-iesg", "dead"), time=last_year)
881-
DocEventFactory(
882-
doc=d,
883-
type="expired_document",
884-
time=last_year + datetime.timedelta(seconds=delta),
885-
)
886-
dead_from_expires.append(d)
887-
dead_from_expires_event_count[d] = d.docevent_set.count()
888-
889-
notified_during_factory_work = mock_notify.call_count
890-
for call_args in mock_notify.call_args_list:
891-
e = call_args.args[0]
892-
self.assertTrue(isinstance(e,DocEvent))
893-
self.assertFalse(hasattr(e,"skip_community_list_notification"))
894-
895-
repair_dead_on_expire()
896-
897-
self.assertEqual(not_dead.docevent_set.count(), not_dead_event_count)
898-
self.assertEqual(
899-
dead_not_from_expires.docevent_set.count(),
900-
dead_not_from_expires_event_count,
901-
)
902-
for d in dead_from_expires:
903-
self.assertEqual(
904-
d.docevent_set.count(), dead_from_expires_event_count[d] + 2
905-
)
906-
self.assertIn(
907-
"due only to document expiry", d.latest_event(type="added_comment").desc
908-
)
909-
self.assertEqual(
910-
d.latest_event(StateDocEvent).desc,
911-
"IESG state changed to <b>I-D Exists</b> from Dead",
912-
)
913-
self.assertEqual(mock_notify.call_count, 4+notified_during_factory_work)
914-
for call_args in mock_notify.call_args_list[-4:]:
915-
e = call_args.args[0]
916-
self.assertTrue(isinstance(e,DocEvent))
917-
self.assertTrue(hasattr(e,"skip_community_list_notification"))
918-
self.assertTrue(e.skip_community_list_notification)
919848

920849
class ExpireLastCallTests(TestCase):
921850
def test_expire_last_call(self):

ietf/doc/tests_tasks.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
generate_idnits2_rfcs_obsoleted_task,
2222
generate_idnits2_rfc_status_task,
2323
notify_expirations_task,
24-
repair_dead_on_expire_task,
2524
)
2625

2726
class TaskTests(TestCase):
@@ -99,10 +98,6 @@ def test_expire_last_calls_task(self, mock_get_expired, mock_expire):
9998
self.assertEqual(mock_expire.call_args_list[1], mock.call(docs[1]))
10099
self.assertEqual(mock_expire.call_args_list[2], mock.call(docs[2]))
101100

102-
@mock.patch("ietf.doc.tasks.repair_dead_on_expire")
103-
def test_repair_dead_on_expire_task(self, mock_repair):
104-
repair_dead_on_expire_task()
105-
self.assertEqual(mock_repair.call_count, 1)
106101

107102
class Idnits2SupportTests(TestCase):
108103
settings_temp_path_overrides = TestCase.settings_temp_path_overrides + ['DERIVED_DIR']

0 commit comments

Comments
 (0)