Skip to content

Commit

Permalink
bokehjsdir() has been deprecated in favor of bokehjs_path() (#1022)
Browse files Browse the repository at this point in the history
* bokehjsdir() has been deprecated in favor of bokehjs_path()

* Apply suggestions from code review

* Added unit test for bokejs_path() import

---------

Co-authored-by: tbg <taylor@gronka.us>
Co-authored-by: sdc50 <sdc50@byu.net>
  • Loading branch information
3 people committed Mar 21, 2024
1 parent 56ea3da commit 85f8e74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 9 additions & 0 deletions tests/unit_tests/test_tethys_portal/test_settings.py
Expand Up @@ -260,3 +260,12 @@ def test_bokeh_django_staticfiles_finder(self, _):
self.assertIn(
"bokeh_django.static.BokehExtensionFinder", settings.STATICFILES_FINDERS
)

@mock.patch("tethys_portal.optional_dependencies.optional_import")
def test_bokehjsdir_compatibility(self, mock_oi):
mock_bokeh_settings = mock.MagicMock()
mock_oi.return_value = mock_bokeh_settings
mock_bokeh_settings.bokehjs_path.side_effect = AttributeError()
reload(settings)
mock_bokeh_settings.bokehjs_path.assert_called_once()
mock_bokeh_settings.bokehjsdir.assert_called_once()
13 changes: 8 additions & 5 deletions tethys_portal/settings.py
Expand Up @@ -37,9 +37,7 @@
from tethys_portal.optional_dependencies import optional_import, has_module

# optional imports
bokeh_settings, bokehjsdir = optional_import(
("settings", "bokehjsdir"), from_module="bokeh.settings"
)
bokeh_settings = optional_import("settings", from_module="bokeh.settings")
bokeh_django = optional_import("bokeh_django")

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -407,8 +405,13 @@
STATICFILES_DIRS = [
BASE_DIR / "static",
]
if has_module(bokehjsdir):
STATICFILES_DIRS.append(bokehjsdir())
if has_module(bokeh_settings):
try:
bokeh_js_dir = bokeh_settings.bokehjs_path()
except AttributeError:
# support bokeh versions < 3.4
bokeh_js_dir = bokeh_settings.bokehjsdir()
STATICFILES_DIRS.append(bokeh_js_dir)

STATICFILES_USE_NPM = TETHYS_PORTAL_CONFIG.pop("STATICFILES_USE_NPM", False)
if STATICFILES_USE_NPM:
Expand Down

0 comments on commit 85f8e74

Please sign in to comment.