Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changing of alert_type on Alert pane #1734

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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