def email_default_context(): class NoEmailViewPerm(MockPerm): def has_permission(self, action, realm_or_resource=None, id=False, version=False): return action != 'EMAIL_VIEW' __contains__ = has_permission context = RenderingContext(Resource('wiki', 'WikiStart'), href=Href('/'), perm=NoEmailViewPerm()) context.req = None # 1.0 FIXME .req shouldn't be required by formatter return context
def test_run_html_formatter(self): wiki_content = "!WikiSyntax" page = self.create_wiki("Dummy wiki", wiki_content) from trac.mimeview.api import RenderingContext context = RenderingContext( page.resource, href=Href('/'), perm=MockPerm(), ) context.req = None # 1.0 FIXME .req shouldn't be required by formatter format_to_html(self.env, context, wiki_content)
def email_default_context(): class NoEmailViewPerm(MockPerm): def has_permission(self, action, realm_or_resource=None, id=False, version=False): return action != 'EMAIL_VIEW' __contains__ = has_permission context = RenderingContext(Resource('wiki', 'WikiStart'), href=Href('/'), perm=NoEmailViewPerm()) context.req = None # 0.13 FIXME .req shouldn't be required by formatter return context
def test_plain_text_content(self): """Render simple plain text content.""" mimeview = Mimeview(self.env) req = MockRequest(self.env) context = RenderingContext(Resource('wiki', 'readme.txt')) context.req = req content = io.BytesIO("""\ Some text. """) rendered = mimeview.render(context, 'text/plain', content) self.assertEqual('<div class="code"><pre>Some text.\n</pre></div>', str(rendered))