Ejemplo n.º 1
0
def test_accordion_basic_constructor(document, comm):
    accordion = Accordion('plain', 'text')

    model = accordion.get_root(document, comm=comm)

    assert isinstance(model, BkColumn)
    assert len(model.children) == 2
    assert all(isinstance(c, Card) for c in model.children)
    card1, card2 = model.children

    assert 'plain' in card1.children[1].text
    assert 'text' in card2.children[1].text
Ejemplo n.º 2
0
def test_accordion_constructor_with_named_objects(document, comm):
    div1, div2 = Div(), Div()
    p1 = Pane(div1, name='Div1')
    p2 = Pane(div2, name='Div2')
    accordion = Accordion(('Tab1', p1), ('Tab2', p2))

    model = accordion.get_root(document, comm=comm)

    assert isinstance(model, BkColumn)
    assert len(model.children) == 2
    assert all(isinstance(c, Card) for c in model.children)
    card1, card2 = model.children

    assert card1.children[0].children[0].text == 'Tab1'
    assert card1.children[1] is div1
    assert card2.children[0].children[0].text == 'Tab2'
    assert card2.children[1] is div2
Ejemplo n.º 3
0
def test_accordion_implicit_constructor(document, comm):
    div1, div2 = Div(), Div()
    p1 = Pane(div1, name='Div1')
    p2 = Pane(div2, name='Div2')
    accordion = Accordion(p1, p2)

    model = accordion.get_root(document, comm=comm)

    assert isinstance(model, BkColumn)
    assert len(model.children) == 2
    assert all(isinstance(c, Card) for c in model.children)
    card1, card2 = model.children

    assert card1.children[0].children[0].text == p1.name == 'Div1'
    assert card1.children[1] is div1
    assert card2.children[0].children[0].text == p2.name == 'Div2'
    assert card2.children[1] is div2
Ejemplo n.º 4
0
def test_accordion_constructor(document, comm):
    div1 = Div()
    div2 = Div()
    accordion = Accordion(('Div1', div1), ('Div2', div2))
    p1, p2 = accordion.objects

    model = accordion.get_root(document, comm=comm)

    assert isinstance(model, BkColumn)
    assert len(model.children) == 2
    assert all(isinstance(c, Card) for c in model.children)
    card1, card2 = model.children

    assert card1.children[0].children[0].text == 'Div1'
    assert card1.children[1] is div1
    assert card2.children[0].children[0].text == 'Div2'
    assert card2.children[1] is div2
Ejemplo n.º 5
0
def test_accordion_active_on_init(document, comm):
    combinations = [[0], [1], [0, 1]]
    for combination in combinations:
        accordion = Accordion("1", "2", active=combination)
        accordion.get_root(document, comm=comm)
        assert accordion.active == combination