Skip to content

Commit

Permalink
Fix changing of alert_type on Alert pane (#1734)
Browse files Browse the repository at this point in the history
* Fix changing of alert_type on Alert pane

* Fixed Markdown test
  • Loading branch information
philippjfr authored Nov 2, 2020
1 parent 203a16c commit 3fdfa32
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion panel/pane/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Alert(Markdown):

priority = 0

_rename=dict(Markdown._rename, alert_type=None)
_rename = dict(Markdown._rename, alert_type=None)

@classmethod
def applies(cls, obj):
Expand Down
2 changes: 1 addition & 1 deletion panel/pane/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Markdown(DivPaneBase):

_target_transforms = {'object': None}

_rerender_params = ['object', 'dedent', 'extensions']
_rerender_params = ['object', 'dedent', 'extensions', 'css_classes']

@classmethod
def applies(cls, obj):
Expand Down
6 changes: 5 additions & 1 deletion panel/tests/pane/test_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ def test_constructor():


@pytest.mark.parametrize(["alert_type"], [(alert_type,) for alert_type in ALERT_TYPES])
def test_alert_type_change(alert_type):
def test_alert_type_change(alert_type, document, comm):
"""Test that an alert can change alert_type"""
alert = Alert(text="This is some text")

model = alert.get_root(document, comm)

alert.alert_type = alert_type
assert set(alert.css_classes) == {"alert", f"alert-{alert_type}"}
assert set(model.css_classes) == {"alert", f"alert-{alert_type}", "markdown"}


def test_existing_css_classes():
"""Test that an alert can change alert_type"""
alert = Alert(text="This is some text", css_classes=["important"])
Expand Down
7 changes: 6 additions & 1 deletion panel/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

py3_only = pytest.mark.skipif(sys.version_info.major < 3, reason="requires Python 3")

from panel.pane.markup import Markdown


def mpl_figure():
import matplotlib.pyplot as plt
Expand All @@ -56,7 +58,10 @@ def check_layoutable_properties(layoutable, model):
assert model.background == '#ffffff'

layoutable.css_classes = ['custom_class']
assert model.css_classes == ['custom_class']
if isinstance(layoutable, Markdown):
assert model.css_classes == ['custom_class', 'markdown']
else:
assert model.css_classes == ['custom_class']

layoutable.width = 500
assert model.width == 500
Expand Down

0 comments on commit 3fdfa32

Please sign in to comment.