示例#1
0
    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, [])
示例#2
0
    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>.',
        )
示例#3
0
    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>.',
        )
示例#4
0
    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