diff --git a/vizro-core/tests/integration/test_navigation.py b/vizro-core/tests/integration/test_navigation.py index 0ad8eed79..771a02eaa 100644 --- a/vizro-core/tests/integration/test_navigation.py +++ b/vizro-core/tests/integration/test_navigation.py @@ -2,7 +2,7 @@ import vizro.models as vm -from asserts import assert_components_equal +from asserts import assert_component_equal from vizro import Vizro from vizro.managers import model_manager @@ -152,4 +152,4 @@ def label_cases(cases, label): def test_navigation_build(dashboard_result, dashboard_expected): result = dashboard_result.navigation.build() expected = dashboard_expected.navigation.build() - assert_components_equal(result, expected) + assert_component_equal(result, expected) diff --git a/vizro-core/tests/tests_utils/asserts.py b/vizro-core/tests/tests_utils/asserts.py index d102d2319..5445dd733 100644 --- a/vizro-core/tests/tests_utils/asserts.py +++ b/vizro-core/tests/tests_utils/asserts.py @@ -23,7 +23,7 @@ def component_to_dict(component: dash.development.base_component.Component) -> d # TODO: implement some sort of depth limit to comparison so can use in high level tests, roll out more widely across # tests -def assert_components_equal(left, right, keys_to_strip=None): +def assert_component_equal(left, right, keys_to_strip=None): # Note we check for None explicitly because {} is a valid value for keys_to_strip. keys_to_strip = keys_to_strip if keys_to_strip is not None else {"id", "class_name", "className"} left = strip_keys(component_to_dict(left), keys_to_strip) diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py index 864e77479..739660285 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py @@ -8,7 +8,7 @@ from pydantic import ValidationError import vizro.models as vm -from asserts import assert_components_equal +from asserts import assert_component_equal from vizro._constants import ACCORDION_DEFAULT_TITLE @@ -111,9 +111,9 @@ class TestAccordionBuild: @pytest.mark.parametrize("pages, expected", test_cases) def test_accordion(self, pages, expected): accordion = vm.Accordion(id="accordion", pages=pages).build(active_page_id="Page 1") - assert_components_equal(accordion, html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"}) - assert_components_equal(accordion["accordion"], expected) + assert_component_equal(accordion, html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"}) + assert_component_equal(accordion["accordion"], expected) def test_accordion_one_page(self): accordion = vm.Accordion(pages={"Group": ["Page 1"]}).build(active_page_id="Page 1") - assert_components_equal(accordion, html.Div(hidden=True, id="nav_panel_outer"), keys_to_strip={}) + assert_component_equal(accordion, html.Div(hidden=True, id="nav_panel_outer"), keys_to_strip={}) diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py index cc276aaf6..0a629534b 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py @@ -8,7 +8,7 @@ import vizro.models as vm import dash_bootstrap_components as dbc -from asserts import assert_components_equal +from asserts import assert_component_equal @pytest.mark.usefixtures("vizro_app", "prebuilt_dashboard") @@ -80,8 +80,8 @@ def test_nav_bar_active_pages_as_dict(self, pages_as_dict): nav_bar.pre_build() built_nav_bar = nav_bar.build(active_page_id="Page 1") expected_button = html.Div([dbc.Button(children=[html.Span(children="filter_1")], active=True, href="/")]) - assert_components_equal(built_nav_bar["nav_bar_outer"], expected_button) - assert_components_equal( + assert_component_equal(built_nav_bar["nav_bar_outer"], expected_button) + assert_component_equal( built_nav_bar["nav_panel_outer"], html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"} ) assert all(isinstance(child, dbc.Accordion) for child in built_nav_bar["nav_panel_outer"].children) @@ -96,8 +96,8 @@ def test_nav_bar_active_pages_as_list(self, pages_as_list): dbc.Button(children=[html.Span(children="filter_2")], active=False, href="/page-2"), ] ) - assert_components_equal(built_nav_bar["nav_bar_outer"], expected_buttons) - assert_components_equal( + assert_component_equal(built_nav_bar["nav_bar_outer"], expected_buttons) + assert_component_equal( built_nav_bar["nav_panel_outer"], html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"} ) assert all(isinstance(child, dbc.Accordion) for child in built_nav_bar["nav_panel_outer"].children) @@ -107,8 +107,8 @@ def test_nav_bar_not_active_pages_as_dict(self, pages_as_dict): nav_bar.pre_build() built_nav_bar = nav_bar.build(active_page_id="Page 3") expected_button = html.Div([dbc.Button(children=[html.Span(children="filter_1")], active=False, href="/")]) - assert_components_equal(built_nav_bar["nav_bar_outer"], expected_button) - assert_components_equal( + assert_component_equal(built_nav_bar["nav_bar_outer"], expected_button) + assert_component_equal( built_nav_bar["nav_panel_outer"], html.Div(hidden=True, id="nav_panel_outer"), keys_to_strip={} ) @@ -122,8 +122,8 @@ def test_nav_bar_active_pages_as_list(self, pages_as_list): dbc.Button(children=[html.Span(children="filter_2")], active=False, href="/page-2"), ] ) - assert_components_equal(built_nav_bar["nav_bar_outer"], expected_buttons) - assert_components_equal( + assert_component_equal(built_nav_bar["nav_bar_outer"], expected_buttons) + assert_component_equal( built_nav_bar["nav_panel_outer"], html.Div(id="nav_panel_outer", hidden=True), keys_to_strip={"children", "className"}, diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py index 4ec0f606b..010e79377 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py @@ -7,7 +7,7 @@ from pydantic import ValidationError import vizro.models as vm -from asserts import assert_components_equal +from asserts import assert_component_equal @pytest.mark.usefixtures("vizro_app", "prebuilt_dashboard") @@ -75,7 +75,7 @@ def test_nav_link_active(self, pages, request): nav_link.pre_build() built_nav_link = nav_link.build(active_page_id="Page 1") expected_button = dbc.Button(id="nav_link", children=[html.Span("icon")], active=True, href="/") - assert_components_equal(built_nav_link["nav_link"], expected_button) + assert_component_equal(built_nav_link["nav_link"], expected_button) assert all(isinstance(child, dbc.Accordion) for child in built_nav_link["nav_panel_outer"].children) def test_nav_link_not_active(self, pages, request): @@ -84,5 +84,5 @@ def test_nav_link_not_active(self, pages, request): nav_link.pre_build() built_nav_link = nav_link.build(active_page_id="Page 3") expected_button = dbc.Button(id="nav_link", children=[html.Span("icon")], active=False, href="/") - assert_components_equal(built_nav_link["nav_link"], expected_button) + assert_component_equal(built_nav_link["nav_link"], expected_button) assert "nav_panel_outer" not in built_nav_link diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py index b167badb1..86577ec11 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py @@ -6,7 +6,7 @@ from pydantic import ValidationError import vizro.models as vm -from asserts import assert_components_equal +from asserts import assert_component_equal import dash_bootstrap_components as dbc @@ -82,12 +82,12 @@ def test_default_nav_selector(self, pages, request): navigation = vm.Navigation(pages=pages) navigation.pre_build() built_navigation = navigation.build(active_page_id="Page 1") - assert_components_equal( + assert_component_equal( built_navigation["nav_bar_outer"], html.Div(className="hidden", id="nav_bar_outer"), keys_to_strip={"children"}, ) - assert_components_equal( + assert_component_equal( built_navigation["nav_panel_outer"], html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"} ) assert all(isinstance(child, dbc.Accordion) for child in built_navigation["nav_panel_outer"].children) @@ -96,12 +96,12 @@ def test_non_default_nav_selector_pags_as_dict(self, pages_as_dict): navigation = vm.Navigation(pages=pages_as_dict, nav_selector=vm.NavBar()) navigation.pre_build() built_navigation = navigation.build(active_page_id="Page 1") - assert_components_equal( + assert_component_equal( built_navigation["nav_bar_outer"], html.Div(id="nav_bar_outer", className="nav-bar"), keys_to_strip={"children"}, ) - assert_components_equal( + assert_component_equal( built_navigation["nav_panel_outer"], html.Div(id="nav_panel_outer"), keys_to_strip={"children", "className"}, @@ -112,12 +112,12 @@ def test_non_default_nav_selector_pages_as_list(self, pages_as_list): navigation = vm.Navigation(pages=pages_as_list, nav_selector=vm.NavBar()) navigation.pre_build() built_navigation = navigation.build(active_page_id="Page 1") - assert_components_equal( + assert_component_equal( built_navigation["nav_bar_outer"], html.Div(id="nav_bar_outer", className="nav-bar"), keys_to_strip={"children"}, ) - assert_components_equal( + assert_component_equal( built_navigation["nav_panel_outer"], html.Div(id="nav_panel_outer", hidden=True), keys_to_strip={"children"},