예제 #1
0
    def test_bad_help_template_tags(self):
        from aristotle_mdr.contrib.help.templatetags import aristotle_help as tags

        page = models.HelpPage()

        rendered = tags.relink(page, 'body')
        self.assertTrue(rendered == "")

        page = models.HelpPage(body="[[some_page]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('unknown model' in rendered)

        page = models.HelpPage(body="[[h|some_page]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('unknown help page' in rendered)
예제 #2
0
    def test_good_help_template_tags(self):
        from aristotle_mdr.contrib.help.templatetags import aristotle_help as tags

        page = models.HelpPage(body="[[aristotle_mdr.Property|s]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('Properties' in rendered)

        rendered = tags.relink_f(page.body)
        self.assertTrue('Properties' in rendered)

        page = models.HelpPage(body="[[aristotle_mdr.Property|su]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('Properties' not in rendered)
        self.assertTrue('class=\'help_link' not in rendered)
        self.assertTrue('aristotle_mdr/property' in rendered)

        rendered = tags.relink_f(page.body)
        self.assertTrue('Properties' not in rendered)
        self.assertTrue('class=\'help_link' not in rendered)
        self.assertTrue('aristotle_mdr/property' in rendered)

        page = models.HelpPage.objects.create(title="myslug", body="")

        page = models.HelpPage(body="[[h|myslug]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('myslug' in rendered)
        self.assertTrue('class=\'help_link' in rendered)

        rendered = tags.relink_f(page.body)
        self.assertTrue('myslug' in rendered)
        self.assertTrue('class=\'help_link' in rendered)

        page = models.HelpPage(body="[[h|myslug|u]]")

        rendered = tags.relink(page, 'body')
        self.assertTrue('myslug' in rendered)
        self.assertTrue('class=\'help_link' not in rendered)