예제 #1
0
 def test_single_model_with_document(self):
     # should use existing doc in with-block
     p = Model()
     d = Document()
     orig_theme = d.theme
     d.add_root(p)
     with beu.OutputDocumentFor([p]):
         assert p.document is d
         assert d.theme is orig_theme
     assert p.document is d
     assert d.theme is orig_theme
예제 #2
0
 def test_passing_doc(self):
     p1 = Model()
     d = Document()
     d.add_root(p1)
     docs_json, render_items = beu.standalone_docs_json_and_render_items([d])
     doc = list(docs_json.values())[0]
     assert doc['title'] == "Bokeh Application"
     assert doc['version'] == __version__
     assert len(doc['roots']['root_ids']) == 1
     assert len(doc['roots']['references']) == 1
     assert doc['roots']['references'] == [{'attributes': {}, 'id': str(p1.id), 'type': 'Model'}]
     assert len(render_items) == 1
예제 #3
0
 def test_setting_built_in_theme_error(self):
     obj = Model()
     doc = Document()
     doc.add_root(obj)
     with pytest.raises(ValueError):
         doc.theme = 1337
예제 #4
0
 def test_setting_built_in_theme_missing(self):
     obj = Model()
     doc = Document()
     doc.add_root(obj)
     with pytest.raises(ValueError):
         doc.theme = 'some_theme_i_guess'
예제 #5
0
 def test_setting_built_in_theme_str(self):
     obj = Model()
     doc = Document()
     doc.add_root(obj)
     doc.theme = DARK_MINIMAL
     assert "#20262B" == doc.theme._json['attrs']['Figure']['background_fill_color']
예제 #6
0
 def test_setting_built_in_theme_obj(self):
     obj = Model()
     doc = Document()
     doc.add_root(obj)
     doc.theme = built_in_themes[LIGHT_MINIMAL]
     assert "#5B5B5B" == doc.theme._json['attrs']['ColorBar']['title_text_color']
예제 #7
0
 class HasFuncDefaultModel(Model):
     child = Instance(Model, lambda: Model())
예제 #8
0
 def test_no_docs(self):
     p1 = Model()
     p2 = Model()
     beu._dispose_temp_doc([p1, p2])
     assert p1.document is None
     assert p2.document is None
예제 #9
0
 def test_no_docs(self):
     p1 = Model()
     p2 = Model()
     beu._create_temp_doc([p1, p2])
     assert isinstance(p1.document, Document)
     assert isinstance(p2.document, Document)
예제 #10
0
 def test_single_model_with_no_document(self):
     p = Model()
     assert p.document is None
     with beu.OutputDocumentFor([p]):
         assert p.document is not None
     assert p.document is not None
예제 #11
0
 def test_succeed_with_one_model(self):
     m = Model()
     assert beu.check_one_model_or_doc(m) is m
예제 #12
0
 def test_single_model(self):
     p = Model()
     self.assertIs(p.document, None)
     with _ModelInDocument([p]):
         self.assertIsNot(p.document, None)
     self.assertIs(p.document, None)
예제 #13
0
 def test_exception_for_missing_doc(self):
     p1 = Model()
     with pytest.raises(ValueError) as e:
         beu.standalone_docs_json_and_render_items([p1])
     assert str(e.value) == "A Bokeh Model must be part of a Document to render as standalone content"
예제 #14
0
 def test_single_model(self):
     p = Model()
     assert p.document is None
     with bes._ModelInDocument([p]):
         assert p.document is not None
     assert p.document is None