def test_template_session_destroy(document, comm): tmplt = Template(template) widget = FloatSlider() row = Row('A', 'B') tmplt.add_panel('A', widget) tmplt.add_panel('B', row) tmplt._init_doc(document, comm, notebook=True) session_context = param.Parameterized() session_context._document = document session_context.id = 'Some ID' assert len(widget._models) == 2 assert len(row._models) == 2 assert len(row[0]._models) == 2 assert len(row[1]._models) == 2 for cb in document.session_destroyed_callbacks: cb(session_context) assert len(widget._models) == 0 assert len(row._models) == 0 assert len(row[0]._models) == 0 assert len(row[1]._models) == 0
def test_template_links_axes(document, comm): tmplt = Template(template) p1 = HoloViews(hv.Curve([1, 2, 3])) p2 = HoloViews(hv.Curve([1, 2, 3])) p3 = HoloViews(hv.Curve([1, 2, 3])) row = Row(p2, p3) tmplt.add_panel('A', p1) tmplt.add_panel('B', row) tmplt._init_doc(document, comm, notebook=True) (_, (m1, _)) = list(p1._models.items())[0] (_, (m2, _)) = list(p2._models.items())[0] (_, (m3, _)) = list(p3._models.items())[0] assert m1.x_range is m2.x_range assert m1.y_range is m2.y_range assert m2.x_range is m3.x_range assert m2.y_range is m3.y_range
def test_template_css(): t = Template("{% extends base %}") t.add_panel('A', 1) css = ".test { color: 'green' }" ntf = NamedTemporaryFile() with open(ntf.name, 'w') as f: f.write(css) t.add_variable('template_css_files', [ntf.name]) server = serve(t, port=5009, threaded=True, show=False) # Wait for server to start time.sleep(1) r = requests.get("http://localhost:5009/") assert css in r.content.decode('utf-8') server.stop()
def test_template_css(): t = Template("{% extends base %}") t.add_panel('A', 1) css = ".test { color: 'green' }" ntf = NamedTemporaryFile() with open(ntf.name, 'w') as f: f.write(css) t.add_variable('template_css_files', [ntf.name]) loop = IOLoop() server = StoppableThread(target=t._get_server, io_loop=loop, args=(5009, None, None, loop, False, True, None, False, None)) server.start() # Wait for server to start time.sleep(1) r = requests.get("http://localhost:5009/") assert css in r.content.decode('utf-8') server.stop()