-
-
Notifications
You must be signed in to change notification settings - Fork 484
/
test_card.py
71 lines (51 loc) · 1.79 KB
/
test_card.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from bokeh.models import Div
from panel.layout import Card
from panel.models import Card as CardModel
from panel.pane import HTML
def test_card_model_cache_cleanup(document, comm):
html = HTML()
l = Card(header=html)
model = l.get_root(document, comm)
ref = model.ref['id']
assert ref in l._models
assert l._models[ref] == (model, None)
assert ref in html._models
l._cleanup(model)
assert l._models == {}
assert html._models == {}
def test_card_get_root(document, comm):
div1 = Div()
div2 = Div()
layout = Card(div1, div2)
model = layout.get_root(document, comm=comm)
ref = model.ref['id']
header = layout._header_layout._models[ref][0]
assert isinstance(model, CardModel)
assert model.children == [header, div1, div2]
assert header.children[0].text == "​"
def test_card_get_root_title(document, comm):
div1 = Div()
div2 = Div()
layout = Card(div1, div2, title='Test')
model = layout.get_root(document, comm=comm)
ref = model.ref['id']
header = layout._header_layout._models[ref][0]
assert isinstance(model, CardModel)
assert model.children == [header, div1, div2]
assert header.children[0].text == '<h3>Test</h3>'
div3 = Div()
layout.header = div3
assert header.children[0] is div3
layout.header = None
assert header.children[0].text == '<h3>Test</h3>'
def test_card_get_root_header(document, comm):
div1 = Div()
div2 = Div()
div3 = Div()
layout = Card(div1, div2, header=div3)
model = layout.get_root(document, comm=comm)
ref = model.ref['id']
header = layout._header_layout._models[ref][0]
assert isinstance(model, CardModel)
assert model.children == [header, div1, div2]
assert header.children[0] is div3