コード例 #1
0
class WikiRendererTestCase(unittest.TestCase):
    def setUp(self):
        self.env = EnvironmentStub()
        self.mod = WikiRenderer(self.env)

    def test_load_stylesheet(self):
        text = textwrap.dedent("""\
            {{{#!text/x-diff
            --- a/file.txt  2014-11-13 01:16:06 +0000
            +++ b/file.txt  2014-11-13 01:16:06 +0000
            @@ -1 +1 @@
            -old line
            +new line
            }}}
            """)
        req = MockRequest(self.env,
                          method='POST',
                          path_info='/wiki_render',
                          args={
                              'id': 'WikiStart',
                              'text': text
                          })

        self.assertTrue(self.mod.match_request(req))
        try:
            self.mod.process_request(req)
            self.fail('RequestDone not raised')
        except RequestDone:
            output = req.response_sent.getvalue()
            self.assertIn('<div class="wiki-code">', output)
            self.assertIn('<table class="trac-diff inline"', output)
            self.assertIn(
                'jQuery.loadStyleSheet("'
                '/trac.cgi/chrome/common/css/diff.css"', output)
コード例 #2
0
ファイル: web_api.py プロジェクト: pkdevbox/trac
class WikiRendererTestCase(unittest.TestCase):

    def setUp(self):
        self.env = EnvironmentStub()
        self.mod = WikiRenderer(self.env)

    def test_load_stylesheet(self):
        buf = StringIO()
        def send(data):
            buf.write(data)
            raise RequestDone

        text = """\
{{{#!text/x-diff
--- a/file.txt  2014-11-13 01:16:06 +0000
+++ b/file.txt  2014-11-13 01:16:06 +0000
@@ -1 +1 @@
-old line
+new line
}}}
"""
        req = Mock(method='POST', path_info='/wiki_render', session={},
                   args={'id': 'WikiStart', 'text': text},
                   abs_href=Href('http://example.com/'), href=Href('/'),
                   chrome={'links': {}, 'scripts': []}, perm=None,
                   authname=None, tz=None, send=send)
        self.assertTrue(self.mod.match_request(req))
        try:
            self.mod.process_request(req)
            self.fail('RequestDone not raised')
        except RequestDone:
            output = buf.getvalue()
            self.assertIn('<div class="code"><pre>', output)
            self.assertIn('jQuery.loadStyleSheet("'
                          '/chrome/common/css/diff.css"', output)
コード例 #3
0
ファイル: web_api.py プロジェクト: dammina/bloodhound
class WikiRendererTestCase(unittest.TestCase):
    def setUp(self):
        self.env = EnvironmentStub()
        self.mod = WikiRenderer(self.env)

    def test_load_stylesheet(self):
        buf = StringIO()

        def send(data):
            buf.write(data)
            raise RequestDone

        text = """\
{{{#!text/x-diff
--- a/file.txt  2014-11-13 01:16:06 +0000
+++ b/file.txt  2014-11-13 01:16:06 +0000
@@ -1 +1 @@
-old line
+new line
}}}
"""
        req = Mock(method='POST',
                   path_info='/wiki_render',
                   session={},
                   args={
                       'id': 'WikiStart',
                       'text': text
                   },
                   abs_href=Href('http://example.com/'),
                   href=Href('/'),
                   chrome={
                       'links': {},
                       'scripts': []
                   },
                   perm=None,
                   authname=None,
                   tz=None,
                   send=send)
        self.assertTrue(self.mod.match_request(req))
        try:
            self.mod.process_request(req)
            self.fail('RequestDone not raised')
        except RequestDone:
            output = buf.getvalue()
            self.assertIn('<div class="code"><pre>', output)
            self.assertIn(
                'jQuery.loadStyleSheet("'
                '/chrome/common/css/diff.css"', output)
コード例 #4
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.mod = WikiRenderer(self.env)
コード例 #5
0
ファイル: web_api.py プロジェクト: pkdevbox/trac
 def setUp(self):
     self.env = EnvironmentStub()
     self.mod = WikiRenderer(self.env)