Test that attributes work with local resources
(mocker)
| 198 | |
| 199 | |
| 200 | def 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 | |
| 235 | def test_multiple_external_urls_with_attributes(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…