Esempio n. 1
0
 def test_no_inject_head(self):
     rl = testapi.request(1, mw)
     js.req(no_inject=True).prepare()
     out = twc.inject_resources(html)
     assert eq_xhtml(
         out,
         '<html><head><title>a</title></head><body>hello</body></html>')
Esempio n. 2
0
 def test_inject_csssrc_twice(self):
     rl = testapi.request(1, mw)
     csssrc.inject()
     csssrc.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(out, '<html><head>\
         <style type="text/css">.bob { font-weight: bold; }</style>\
         <title>a</title></head><body>hello</body></html>')
Esempio n. 3
0
 def test_inject_jssrc_twice(self):
     rl = testapi.request(1, mw)
     jssrc.inject()
     jssrc.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(out, '<html><head>\
         <title>a</title></head><body>hello<script type="text/javascript">bob</script>\
         </body></html>')
Esempio n. 4
0
 def test_inject_head(self):
     rl = testapi.request(1, mw)
     js.inject()
     csssrc.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(out, '<html><head><script type="text/javascript" src="paj"></script>\
         <style type="text/css">.bob { font-weight: bold; }</style>\
         <title>a</title></head><body>hello</body></html>')
Esempio n. 5
0
 def test_inject_css(self):
     rl = testapi.request(1, mw)
     csssrc.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(
         out,
         '<html><head><style type="text/css">.bob { font-weight: bold; }</style>\
         <title>a</title></head><body>hello</body></html>')
Esempio n. 6
0
 def test_inject_body(self):
     rl = testapi.request(1, mw)
     jssrc.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(
         out,
         '<html><head><title>a</title></head><body>hello<script type="text/javascript">bob</script></body></html>'
     )
Esempio n. 7
0
 def test_detect_clear(self):
     widget = twc.Widget(id='a', template='genshi:tw2.core.test_templates.inner_genshi', test='test', resources=[js])
     rl = testapi.request(1, mw)
     eq_(rl.get('resources', []), [])
     widget.display()
     rl = twc.core.request_local()
     assert(len(rl.get('resources', [])) == 1)
     out = twc.inject_resources(html)
     eq_(rl.get('resources', []), [])
Esempio n. 8
0
 def test_inject_js_twice(self):
     rl = testapi.request(1, mw)
     js.inject()
     js.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(
         out, '<html><head>\
         <script type="text/javascript" src="paj"></script>\
         <title>a</title></head><body>hello</body></html>')
Esempio n. 9
0
 def test_inject_head(self):
     rl = testapi.request(1, mw)
     js.inject()
     csssrc.inject()
     out = twc.inject_resources(html)
     print out
     assert eq_xhtml(
         out,
         '<html><head><script type="text/javascript" src="paj"></script>\
         <style type="text/css">.bob { font-weight: bold; }</style>\
         <title>a</title></head><body>hello</body></html>')
Esempio n. 10
0
 def test_detect_clear(self):
     widget = twc.Widget(
         id='a',
         template='genshi:tw2.core.test_templates.inner_genshi',
         test='test',
         resources=[js])
     rl = testapi.request(1, mw)
     eq_(rl.get('resources', []), [])
     widget.display()
     rl = twc.core.request_local()
     assert (len(rl.get('resources', [])) == 1)
     out = twc.inject_resources(html)
     eq_(rl.get('resources', []), [])
Esempio n. 11
0
 def test_no_inject_head(self):
     rl = testapi.request(1, mw)
     js.req(no_inject=True).prepare()
     out = twc.inject_resources(html)
     assert eq_xhtml(out, '<html><head><title>a</title></head><body>hello</body></html>')
Esempio n. 12
0
 def test_inject_head(self):
     rl = testapi.request(1, mw)
     js.inject()
     out = twc.inject_resources(html)
     assert eq_xhtml(out, '<html><head><script type="text/javascript" src="paj"></script><title>a</title></head><body>hello</body></html>')