File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -618,7 +618,10 @@ def _collect_and_register_resources(self, resources):
618
618
# add the version number of the package as a query parameter
619
619
# for cache busting
620
620
def _relative_url_path (relative_package_path = "" , namespace = "" ):
621
- if any (x in relative_package_path for x in ["dcc" , "html" , "dash_table" ]):
621
+ if any (
622
+ relative_package_path .startswith (x + "/" )
623
+ for x in ["dcc" , "html" , "dash_table" ]
624
+ ):
622
625
relative_package_path = relative_package_path .replace ("dash." , "" )
623
626
version = importlib .import_module (
624
627
"{}.{}" .format (namespace , os .path .split (relative_package_path )[0 ])
Original file line number Diff line number Diff line change @@ -102,3 +102,23 @@ def test_internal(mocker):
102
102
), "Dynamic resource not available in registered path {}" .format (
103
103
app .registered_paths ["dash" ]
104
104
)
105
+
106
+
107
+ def test_collect_and_register_resources (mocker ):
108
+
109
+ app = dash .Dash (
110
+ __name__ , assets_folder = "tests/assets" , assets_ignore = "load_after.+.js"
111
+ )
112
+ with mock .patch ("dash.dash.os.stat" , return_value = StatMock ()):
113
+ with mock .patch ("dash.dash.importlib.import_module" ) as import_mock :
114
+ with mock .patch ("sys.modules" , {"dash_html_components" : dcc }):
115
+ import_mock .return_value = dcc
116
+ app ._collect_and_register_resources (
117
+ [
118
+ {
119
+ "namespace" : "dash_html_components" ,
120
+ "relative_package_path" : "dash_html_components.min.js" ,
121
+ },
122
+ ]
123
+ )
124
+ import_mock .assert_any_call ("dash_html_components" )
You can’t perform that action at this time.
0 commit comments