fix: repairs reflecting removal of DocAlias from the RelatedDocument models
This commit is contained in:
parent
1ad19e0256
commit
51c22d8e6c
|
@ -52,8 +52,13 @@ class IndexTests(TestCase):
|
|||
|
||||
RelatedDocument.objects.create(
|
||||
relationship=DocRelationshipName.objects.get(slug="replaces"),
|
||||
source=Document.objects.create(type_id="draft", rev="00", name="draft-test-replacement"),
|
||||
target=draft.docalias.get(name__startswith="draft"))
|
||||
source=Document.objects.create(
|
||||
type_id="draft",
|
||||
rev="00",
|
||||
name="draft-test-replacement"
|
||||
),
|
||||
target=draft
|
||||
)
|
||||
|
||||
txt = all_id_txt()
|
||||
self.assertTrue(draft.name + "-" + draft.rev in txt)
|
||||
|
@ -111,8 +116,12 @@ class IndexTests(TestCase):
|
|||
draft.set_state(State.objects.get(type="draft", slug="repl"))
|
||||
RelatedDocument.objects.create(
|
||||
relationship=DocRelationshipName.objects.get(slug="replaces"),
|
||||
source=Document.objects.create(type_id="draft", rev="00", name="draft-test-replacement"),
|
||||
target=draft.docalias.get(name__startswith="draft"))
|
||||
source=Document.objects.create(
|
||||
type_id="draft",
|
||||
rev="00",
|
||||
name="draft-test-replacement"
|
||||
),
|
||||
target=draft)
|
||||
|
||||
t = get_fields(all_id2_txt())
|
||||
self.assertEqual(t[5], "draft-test-replacement")
|
||||
|
|
|
@ -108,7 +108,7 @@ class IESGAgendaTests(TestCase):
|
|||
mars = GroupFactory(acronym='mars',parent=Group.objects.get(acronym='farfut'))
|
||||
wgdraft = WgDraftFactory(name='draft-ietf-mars-test', group=mars, intended_std_level_id='ps')
|
||||
rfc = IndividualRfcFactory.create(stream_id='irtf', rfc_number=6666, std_level_id='inf', )
|
||||
wgdraft.relateddocument_set.create(target=rfc.docalias.get(name='rfc6666'), relationship_id='refnorm')
|
||||
wgdraft.relateddocument_set.create(target=rfc, relationship_id='refnorm')
|
||||
ise_draft = IndividualDraftFactory(name='draft-imaginary-independent-submission')
|
||||
ise_draft.stream = StreamName.objects.get(slug="ise")
|
||||
ise_draft.save_with_history([DocEvent(doc=ise_draft, rev=ise_draft.rev, type="changed_stream", by=Person.objects.get(user__username="secretary"), desc="Test")])
|
||||
|
@ -238,7 +238,7 @@ class IESGAgendaTests(TestCase):
|
|||
|
||||
relation = RelatedDocument.objects.create(
|
||||
source=statchg,
|
||||
target=DocAlias.objects.filter(name__startswith='rfc', docs__std_level="ps")[0],
|
||||
target=Document.objects.filter(type_id="rfc", std_level="ps").first(),
|
||||
relationship_id="tohist")
|
||||
|
||||
statchg.group = Group.objects.get(acronym="mars")
|
||||
|
@ -256,7 +256,7 @@ class IESGAgendaTests(TestCase):
|
|||
self.assertTrue(statchg in agenda_data(date_str)["sections"]["2.3.3"]["docs"])
|
||||
|
||||
# 3.3 document status changes
|
||||
relation.target = DocAlias.objects.filter(name__startswith='rfc', docs__std_level="inf")[0]
|
||||
relation.target = Document.objects.filter(type_id="rfc", std_level="inf").first()
|
||||
relation.save()
|
||||
|
||||
statchg.group = Group.objects.get(acronym="mars")
|
||||
|
|
|
@ -68,8 +68,7 @@ class SecrTelechatTestCase(TestCase):
|
|||
ad = Person.objects.get(user__username="ad")
|
||||
draft = WgDraftFactory(ad=ad, intended_std_level_id='ps', states=[('draft-iesg','pub-req'),])
|
||||
rfc = IndividualRfcFactory.create(stream_id='irtf', rfc_number=6666, std_level_id='inf')
|
||||
draft.relateddocument_set.create(target=rfc.docalias.get(name='rfc6666'),
|
||||
relationship_id='refnorm')
|
||||
draft.relateddocument_set.create(target=rfc, relationship_id='refnorm')
|
||||
create_ballot_if_not_open(None, draft, ad, 'approve')
|
||||
d = get_next_telechat_date()
|
||||
date = d.strftime('%Y-%m-%d')
|
||||
|
|
|
@ -563,11 +563,11 @@ def document_stats(request, stats_type=None):
|
|||
bins = defaultdict(set)
|
||||
|
||||
cite_relationships = list(DocRelationshipName.objects.filter(slug__in=['refnorm', 'refinfo', 'refunk', 'refold']))
|
||||
person_filters &= Q(documentauthor__document__docalias__relateddocument__relationship__in=cite_relationships)
|
||||
person_filters &= Q(documentauthor__document__relateddocument__relationship__in=cite_relationships)
|
||||
|
||||
person_qs = Person.objects.filter(person_filters)
|
||||
|
||||
for name, citations in person_qs.values_list("name").annotate(Count("documentauthor__document__docalias__relateddocument")):
|
||||
for name, citations in person_qs.values_list("name").annotate(Count("documentauthor__document__relateddocument")):
|
||||
bins[citations or 0].add(name)
|
||||
|
||||
total_persons = count_bins(bins)
|
||||
|
@ -587,11 +587,11 @@ def document_stats(request, stats_type=None):
|
|||
bins = defaultdict(set)
|
||||
|
||||
cite_relationships = list(DocRelationshipName.objects.filter(slug__in=['refnorm', 'refinfo', 'refunk', 'refold']))
|
||||
person_filters &= Q(documentauthor__document__docalias__relateddocument__relationship__in=cite_relationships)
|
||||
person_filters &= Q(documentauthor__document__relateddocument__relationship__in=cite_relationships)
|
||||
|
||||
person_qs = Person.objects.filter(person_filters)
|
||||
|
||||
values = person_qs.values_list("name", "documentauthor__document").annotate(Count("documentauthor__document__docalias__relateddocument"))
|
||||
values = person_qs.values_list("name", "documentauthor__document").annotate(Count("documentauthor__document__relateddocument"))
|
||||
for name, ts in itertools.groupby(values.order_by("name"), key=lambda t: t[0]):
|
||||
h_index = compute_hirsch_index([citations for _, document, citations in ts])
|
||||
bins[h_index or 0].add(name)
|
||||
|
|
|
@ -302,7 +302,7 @@ class SubmitTests(BaseSubmitTestCase):
|
|||
submission = Submission.objects.get(name=name)
|
||||
self.assertEqual(submission.submitter, email.utils.formataddr((submitter_name, submitter_email)))
|
||||
self.assertEqual([] if submission.replaces == "" else submission.replaces.split(','),
|
||||
[ d.name for d in DocAlias.objects.filter(pk__in=replaces) ])
|
||||
[ d.name for d in Document.objects.filter(pk__in=replaces) ])
|
||||
self.assertCountEqual(
|
||||
[str(r) for r in submission.external_resources.all()],
|
||||
[str(r) for r in extresources] if extresources else [],
|
||||
|
@ -418,7 +418,7 @@ class SubmitTests(BaseSubmitTestCase):
|
|||
self.assertEqual(authors[0].person, author)
|
||||
self.assertEqual(set(draft.formal_languages.all()), set(FormalLanguageName.objects.filter(slug="json")))
|
||||
self.assertEqual(draft.relations_that_doc("replaces").count(), 1)
|
||||
self.assertTrue(draft.relations_that_doc("replaces").first().target, replaced_alias)
|
||||
self.assertTrue(draft.relations_that_doc("replaces").first().target, draft)
|
||||
self.assertEqual(draft.relations_that_doc("possibly-replaces").count(), 1)
|
||||
self.assertTrue(draft.relations_that_doc("possibly-replaces").first().target, sug_replaced_alias)
|
||||
self.assertEqual(len(outbox), mailbox_before + 5)
|
||||
|
@ -3097,7 +3097,7 @@ class SubmissionUploadFormTests(BaseSubmitTestCase):
|
|||
files=files_dict,
|
||||
)
|
||||
self.assertFalse(form.is_valid())
|
||||
self.assertIn('An Internet-Draft can only replace another Internet-Draft that has become an RFC', form.errors['replaces'])
|
||||
self.assertIn('An Internet-Draft cannot replace another Internet-Draft that has become an RFC', form.errors['replaces'])
|
||||
|
||||
# can't replace draft approved by iesg
|
||||
existing_drafts[0].set_state(State.objects.get(type='draft-iesg', slug='approved'))
|
||||
|
|
|
@ -360,7 +360,7 @@ class RFCSyncTests(TestCase):
|
|||
self.assertTrue(DocAlias.objects.filter(name="bcp1", docs=doc))
|
||||
self.assertTrue(DocAlias.objects.filter(name="fyi1", docs=doc))
|
||||
self.assertTrue(DocAlias.objects.filter(name="std1", docs=doc))
|
||||
self.assertTrue(RelatedDocument.objects.filter(source=doc, target__name="rfc123", relationship="updates"))
|
||||
self.assertTrue(RelatedDocument.objects.filter(source=doc, target__name="rfc123", relationship="updates").exists())
|
||||
self.assertEqual(doc.title, "A Testing RFC")
|
||||
self.assertEqual(doc.abstract, "This is some interesting text.")
|
||||
self.assertEqual(doc.get_state_slug(), "rfc")
|
||||
|
@ -602,4 +602,4 @@ class RFCEditorUndoTests(TestCase):
|
|||
e = DeletedEvent.objects.all().order_by("-time", "-id")[0]
|
||||
|
||||
e.content_type.model_class().objects.create(**json.loads(e.json))
|
||||
self.assertTrue(StateDocEvent.objects.filter(desc="First", doc=draft))
|
||||
self.assertTrue(StateDocEvent.objects.filter(desc="First", doc=draft))
|
||||
|
|
Loading…
Reference in a new issue