Beispiel #1
0
 def test_hello_world(self):
     app = bottle.Bottle()
     br = bottlereact.BottleReact(app, prod=True)
     html = br.render_html(br.HelloWorld())
     self.assertTrue(html.startswith('<html>'))
     self.assertTrue('-bottlereact.js"></script>' in html)
     self.assertTrue('-hello_world.js"></script>' in html)
     self.assertTrue(
         'React.createElement(bottlereact.HelloWorld,{},[])' in html)
Beispiel #2
0
 def test_default_kwarg(self):
     app = bottle.Bottle()
     br = bottlereact.BottleReact(
         app, prod=True, default_render_html_kwargs={'title': 'abc'})
     html = br.render_html(br.HelloWorld(), template='title').strip()
     self.assertEquals(html, 'abc')
     html = br.render_html(br.HelloWorld(), template='title',
                           title='xyz').strip()
     self.assertEquals(html, 'xyz')
Beispiel #3
0
    def test_hello_world_server_side_render_callable(self):
        app = bottle.Bottle()
        br = bottlereact.BottleReact(app, prod=True)

        def f():
            return True

        html = br.render_html(br.HelloWorld(), render_server=f)
        self.assertTrue('Thanks for trying' in html)
Beispiel #4
0
 def test_hello_world_server_side_render_died(self):
     app = bottle.Bottle()
     br = bottlereact.BottleReact(app, prod=True)
     html = br.render_html(br.HelloWorld(), render_server=True)
     self.assertTrue('Thanks for trying' in html)
     self.assertEqual(len(br._ctxs), 1)
     port, child = list(br._ctxs.values())[0]
     child.kill()
     html = br.render_html(br.HelloWorld(), render_server=True)
     self.assertEqual(len(br._ctxs), 1)
Beispiel #5
0
 def test_kwarg(self):
     app = bottle.Bottle()
     br = bottlereact.BottleReact(app, prod=True)
     html = br.render_html(br.HelloWorld(), template='title',
                           title='xyz').strip()
     self.assertEqual(html, 'xyz')