Skip to content

Commit

Permalink
Fixed flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 30, 2020
1 parent e6f68ac commit 98b6fe2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 70 deletions.
2 changes: 2 additions & 0 deletions panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class _state(param.Parameterized):
# Stores a set of locked Websockets, reset after every change event
_locks = WeakSet()

_curdoc = None

def __repr__(self):
server_info = []
for server, panel, docs in self._servers.values():
Expand Down
48 changes: 26 additions & 22 deletions panel/models/location.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
"""This module provides a Bokeh Location Model as a wrapper around the JS window.location api"""
import pathlib

from typing import List, Optional

import param

from bokeh.core.properties import Bool, Instance, Int, String
from bokeh.layouts import column
from bokeh.core.properties import Bool, String
from bokeh.models import Model


class Location(Model):
"""A python wrapper around the JS `window.location` api. See
"""
A python wrapper around the JS `window.location` api. See
https://www.w3schools.com/js/js_window_location.asp and
https://www.w3.org/TR/html52/browsers.html#the-location-interface
You can use this model to provide (parts of) the app state to the user as a bookmarkable and
shareable link.
You can use this model to provide (parts of) the app state to the
user as a bookmarkable and shareable link.
"""

href = String(default="", help="The full url, e.g. 'https://localhost:80?color=blue#interact'")
href = String(default="", help="""
The full url, e.g. 'https://localhost:80?color=blue#interact'""")

hostname = String(default="", help="""
hostname in window.location e.g. 'panel.holoviz.org'""")

pathname = String(default="", help="""
pathname in window.location e.g. '/user_guide/Interact.html'""")

protocol = String(default="", help="""
protocol in window.location e.g. 'https'""")

hostname = String(default="", help="hostname in window.location e.g. 'panel.holoviz.org'")
port = String(default="", help="""
port in window.location e.g. 80""")

pathname = String(default="", help="pathname in window.location e.g. '/user_guide/Interact.html'")
search = String(default="", help="""
search in window.location e.g. '?color=blue'""")

protocol = String(default="", help="protocol in window.location e.g. 'https'")
port = String(default="", help="port in window.location e.g. 80")
search = String(default="", help="search in window.location e.g. '?color=blue'")
hash_ = String(default="", help="hash in window.location e.g. '#interact'")
hash_ = String(default="", help="""
hash in window.location e.g. '#interact'""")

reload = Bool(
default=True,
help="""Reload the page when the location is updated. For multipage apps this should be \
set to True, For single page apps this should be set to False""",
)
reload = Bool(default=True, help="""
Reload the page when the location is updated. For multipage apps
this should be set to True, For single page apps this should be
set to False""")
82 changes: 35 additions & 47 deletions panel/tests/models/test_location.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
"""In this module we test the Bokeh Location Model"""

import pytest
import panel as pn
from panel.models.location import Location


def test_constructor():
# When
actual = Location()
# Then
assert actual.href == ""
assert actual.hostname == ""
assert actual.pathname == ""
assert actual.protocol == ""
assert actual.port == ""
assert actual.search == ""
assert actual.hash_ == ""
assert actual.reload == True


def test_constructor_with__href():
# Given
href = "https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact"
# When
actual = Location(
href="https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact"
)
# Then
assert actual.href == href
assert actual.hostname == ""
assert actual.pathname == ""
assert actual.protocol == ""
assert actual.port == ""
assert actual.search == ""
assert actual.hash_ == ""
assert actual.reload == True


def test_manual():
bkmodel = pn.pane.Bokeh(Location())
app = pn.Column(bkmodel)
return app


if __name__.startswith("bk"):
test_manual().servable()
import panel as pn

from panel.models.location import Location


def test_constructor():
# When
actual = Location()
# Then
assert actual.href == ""
assert actual.hostname == ""
assert actual.pathname == ""
assert actual.protocol == ""
assert actual.port == ""
assert actual.search == ""
assert actual.hash_ == ""
assert actual.reload == True


def test_constructor_with__href():
# Given
href = "https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact"
# When
actual = Location(
href="https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact"
)
# Then
assert actual.href == href
assert actual.hostname == ""
assert actual.pathname == ""
assert actual.protocol == ""
assert actual.port == ""
assert actual.search == ""
assert actual.hash_ == ""
assert actual.reload == True
2 changes: 1 addition & 1 deletion panel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def edit_readonly(parameterized):
p.constant = False
try:
yield
except:
except Exception:
raise
finally:
for (p, readonly) in zip(params, readonlys):
Expand Down

0 comments on commit 98b6fe2

Please sign in to comment.