def test_process_footnotes_no_footnotes(self): rules = Rule.objects.none() notes = RulesDocumentFootnote.objects.none() processed_footnotes = process_footnotes(rules, notes) self.assertEqual(processed_footnotes, [])
def test_process_footnotes_alphabetical_notes(self): rule = mixer.blend(Rule, rule_text="This has a footnote [a].") note = mixer.blend(RulesDocumentFootnote, identifier="001") processed_footnotes = process_footnotes([rule], [note]) self.assertEqual(processed_footnotes, [note]) self.assertEqual( rule.rule_text, 'This has a footnote <sup><a href="#roo_note_1" class="govuk-link">1)</a></sup>.', )
def test_process_footnotes_with_filtering(self): rule = mixer.blend(Rule, rule_text="This has a footnote [002].") note_001 = mixer.blend(RulesDocumentFootnote, identifier="001") note_002 = mixer.blend(RulesDocumentFootnote, identifier="002") note_003 = mixer.blend(RulesDocumentFootnote, identifier="003") processed_footnotes = process_footnotes([rule], [note_001, note_002, note_003]) self.assertEqual(processed_footnotes, [note_002]) self.assertEqual( rule.rule_text, 'This has a footnote <sup><a href="#roo_note_1" class="govuk-link">1)</a></sup>.', )
def get_rules_footnotes(self, rules_document, rules): footnotes = rules_document.footnotes.order_by("id") relevant_footnotes = process_footnotes(rules, footnotes) return footnotes, relevant_footnotes