MCPcopy Index your code
hub / github.com/plotly/dash / test_local_resources_with_attributes

Function test_local_resources_with_attributes

tests/unit/test_resources.py:200–232  ·  view source on GitHub ↗

Test that attributes work with local resources

(mocker)

Source from the content-addressed store, hash-verified

198
199
200def test_local_resources_with_attributes(mocker):
201 """Test that attributes work with local resources"""
202 mocker.patch("dash.dcc._js_dist")
203 mocker.patch("dash.dcc.__version__")
204 dcc._js_dist = [
205 {
206 "relative_package_path": "module.js",
207 "namespace": "dash_core_components",
208 "attributes": {"type": "module"},
209 }
210 ]
211 dcc.__version__ = "1.0.0"
212
213 app = dash.Dash(__name__)
214 app.layout = dcc.Markdown()
215
216 with mock.patch("dash.dash.os.stat", return_value=StatMock()):
217 with mock.patch("dash.dash.importlib.import_module", return_value=dcc):
218 with mock.patch("sys.modules", {"dash_core_components": dcc}):
219 resources = app._collect_and_register_resources(
220 [
221 {
222 "relative_package_path": "module.js",
223 "namespace": "dash_core_components",
224 "attributes": {"type": "module"},
225 }
226 ]
227 )
228
229 assert len(resources) == 1
230 assert isinstance(resources[0], dict)
231 assert "src" in resources[0]
232 assert resources[0]["type"] == "module"
233
234
235def test_multiple_external_urls_with_attributes():

Callers

nothing calls this directly

Calls 2

StatMockClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…