Skip to content

Commit fa35884

Browse files
committed
fixed tests
1 parent cd13276 commit fa35884

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

dash/_get_paths.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66

77
def get_asset_url(path):
8-
return real_get_assets_url(CONFIG, path)
8+
return real_get_asset_url(CONFIG, path)
99

1010

11-
def real_get_assets_url(config, path):
11+
def real_get_asset_url(config, path):
1212
if config.assets_external_path:
1313
prefix = config.assets_external_path
1414
else:
@@ -60,11 +60,10 @@ def display_content(path):
6060
return chapters.page_2
6161
```
6262
"""
63-
return real_get_relative_path(CONFIG, path)
63+
return real_get_relative_path(CONFIG.requests_pathname_prefix, path)
6464

6565

66-
def real_get_relative_path(config, path):
67-
requests_pathname = config.requests_pathname_prefix
66+
def real_get_relative_path(requests_pathname, path):
6867
if requests_pathname == "/" and path == "":
6968
return "/"
7069
if requests_pathname != "/" and path == "":
@@ -128,11 +127,10 @@ def display_content(path):
128127
`page-1/sub-page-1`
129128
```
130129
"""
131-
return real_strip_relative_path(CONFIG, path)
130+
return real_strip_relative_path(CONFIG.requests_pathname_prefix, path)
132131

133132

134-
def real_strip_relative_path(config, path):
135-
requests_pathname = config.requests_pathname_prefix
133+
def real_strip_relative_path(requests_pathname, path):
136134
if path is None:
137135
return None
138136
if (

dash/dash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ def csp_hashes(self, hash_algorithm="sha256"):
14731473
]
14741474

14751475
def get_asset_url(self, path):
1476-
return _get_paths.real_get_assets_url(self.config, path)
1476+
return _get_paths.real_get_asset_url(self.config, path)
14771477

14781478
def get_relative_path(self, path):
14791479
"""
@@ -1737,7 +1737,7 @@ def enable_dev_tools(
17371737
if hasattr(package, "path") and "dash/dash" in os.path.dirname(
17381738
package.path
17391739
):
1740-
component_packages_dist[i: i + 1] = [
1740+
component_packages_dist[i : i + 1] = [
17411741
os.path.join(os.path.dirname(package.path), x)
17421742
for x in ["dcc", "html", "dash_table"]
17431743
]

tests/unit/test_configs.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
get_combined_config,
1414
load_dash_env_vars,
1515
)
16-
from dash import get_asset_path, get_relative_path, strip_relative_path
16+
17+
from dash._utils import AttributeDict
18+
from dash._get_paths import (
19+
real_get_asset_url,
20+
real_get_relative_path,
21+
real_strip_relative_path,
22+
)
1723

1824

1925
@pytest.fixture
@@ -101,7 +107,8 @@ def test_pathname_prefix_environ_requests(empty_environ):
101107
],
102108
)
103109
def test_pathname_prefix_assets(empty_environ, req, expected):
104-
path = get_asset_path(req, "reset.css", "assets")
110+
config = AttributeDict(assets_external_path=req, assets_url_path="assets")
111+
path = real_get_asset_url(config, "reset.css")
105112
assert path == expected
106113

107114

@@ -209,7 +216,7 @@ def test_app_name_server(empty_environ, name, server, expected):
209216
],
210217
)
211218
def test_pathname_prefix_relative_url(prefix, partial_path, expected):
212-
path = get_relative_path(prefix, partial_path)
219+
path = real_get_relative_path(prefix, partial_path)
213220
assert path == expected
214221

215222

@@ -219,7 +226,7 @@ def test_pathname_prefix_relative_url(prefix, partial_path, expected):
219226
)
220227
def test_invalid_get_relative_path(prefix, partial_path):
221228
with pytest.raises(_exc.UnsupportedRelativePath):
222-
get_relative_path(prefix, partial_path)
229+
real_get_relative_path(prefix, partial_path)
223230

224231

225232
@pytest.mark.parametrize(
@@ -247,7 +254,7 @@ def test_invalid_get_relative_path(prefix, partial_path):
247254
],
248255
)
249256
def test_strip_relative_path(prefix, partial_path, expected):
250-
path = strip_relative_path(prefix, partial_path)
257+
path = real_strip_relative_path(prefix, partial_path)
251258
assert path == expected
252259

253260

@@ -261,7 +268,7 @@ def test_strip_relative_path(prefix, partial_path, expected):
261268
)
262269
def test_invalid_strip_relative_path(prefix, partial_path):
263270
with pytest.raises(_exc.UnsupportedRelativePath):
264-
strip_relative_path(prefix, partial_path)
271+
real_strip_relative_path(prefix, partial_path)
265272

266273

267274
def test_port_env_fail_str(empty_environ):

0 commit comments

Comments
 (0)