from __future__ import absolute_import

import pytest

import param

from panel.interact import interactive
from panel.pane import Pane, PaneBase, Bokeh, HoloViews
from panel.param import ParamMethod
from panel._testing.util import check_layoutable_properties

all_panes = [w for w in param.concrete_descendents(PaneBase).values()
             if not w.__name__.startswith('_') and not
             issubclass(w, (Bokeh, HoloViews, ParamMethod, interactive))]


def test_pane_repr(document, comm):
    pane = Pane('Some text', width=400)
    assert repr(pane) == 'Markdown(str, width=400)'


@pytest.mark.parametrize('pane', all_panes)
def test_pane_layout_properties(pane, document, comm):
    p = pane()
    model = p.get_root(document, comm)
    check_layoutable_properties(p, model)


@pytest.mark.parametrize('pane', all_panes)
def test_pane_clone(pane):
    p = pane()
    clone = p.clone()

    assert ([(k, v) for k, v in sorted(p.param.get_param_values()) if k != 'name'] ==
            [(k, v) for k, v in sorted(clone.param.get_param_values()) if k != 'name'])

