Skip to content

Commit

Permalink
Lint and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Dec 20, 2023
1 parent b98e046 commit 356dc2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ 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_component_equal(
accordion, html.Div(id="nav-panel"), keys_to_strip={"children"}
)
assert_component_equal(accordion, html.Div(id="nav-panel"), keys_to_strip={"children"})
assert_component_equal(accordion["accordion"], expected, keys_to_strip={"class_name", "className"})

def test_accordion_one_page(self):
Expand Down
16 changes: 3 additions & 13 deletions vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ def test_nav_bar_active_pages_as_dict(self, pages_as_dict):
]
)
assert_component_equal(built_nav_bar["nav-bar"], expected_button, keys_to_strip={"id", "className"})
assert_component_equal(
built_nav_bar["nav-panel"],
html.Div(id="nav-panel", className="nav_panel"),
keys_to_strip={"children"},
)
assert_component_equal(built_nav_bar["nav-panel"], html.Div(id="nav-panel"), keys_to_strip={"children"})
assert_component_equal(built_nav_bar["nav-panel"].children, [dbc.Accordion()], keys_to_strip=STRIP_ALL)

def test_nav_bar_active_pages_as_list(self, pages_as_list):
Expand All @@ -120,10 +116,7 @@ def test_nav_bar_active_pages_as_list(self, pages_as_list):
]
)
assert_component_equal(built_nav_bar["nav-bar"], expected_buttons, keys_to_strip={"id", "className"})
assert_component_equal(
built_nav_bar["nav-panel"],
html.Div(id="nav-panel", hidden=True),
)
assert_component_equal(built_nav_bar["nav-panel"], html.Div(id="nav-panel", hidden=True))

def test_nav_bar_not_active_pages_as_dict(self, pages_as_dict):
nav_bar = vm.NavBar(pages=pages_as_dict)
Expand Down Expand Up @@ -160,7 +153,4 @@ def test_nav_bar_not_active_pages_as_list(self, pages_as_list):
]
)
assert_component_equal(built_nav_bar["nav-bar"], expected_buttons, keys_to_strip={"id", "className"})
assert_component_equal(
built_nav_bar["nav-panel"],
html.Div(id="nav-panel", hidden=True),
)
assert_component_equal(built_nav_bar["nav-panel"], html.Div(id="nav-panel", hidden=True))
24 changes: 4 additions & 20 deletions vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,22 @@ def test_default_nav_selector(self, pages, request):
navigation.pre_build()
built_navigation = navigation.build(active_page_id="Page 1")
assert_component_equal(built_navigation["nav-bar"], html.Div(hidden=True, id="nav-bar"))
assert_component_equal(
built_navigation["nav-panel"],
html.Div(id="nav-panel"),
keys_to_strip={"children"},
)
assert_component_equal(built_navigation["nav-panel"], html.Div(id="nav-panel"), keys_to_strip={"children"})
assert_component_equal(built_navigation["nav-panel"].children, [dbc.Accordion()], keys_to_strip=STRIP_ALL)

def test_non_default_nav_selector_pags_as_dict(self, pages_as_dict, built_nav_link=None):
navigation = vm.Navigation(pages=pages_as_dict, nav_selector=vm.NavBar())
navigation.pre_build()
built_navigation = navigation.build(active_page_id="Page 1")
assert_component_equal(
built_navigation["nav-bar"],
html.Div(id="nav-bar"),
keys_to_strip={"children"},
)
assert_component_equal(
built_navigation["nav-panel"],
html.Div(id="nav-panel"),
keys_to_strip={"children"},
)
assert_component_equal(built_navigation["nav-bar"], html.Div(id="nav-bar"), keys_to_strip={"children"})
assert_component_equal(built_navigation["nav-panel"], html.Div(id="nav-panel"), keys_to_strip={"children"})
assert_component_equal(built_navigation["nav-panel"].children, [dbc.Accordion()], keys_to_strip=STRIP_ALL)

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_component_equal(
built_navigation["nav-bar"],
html.Div(id="nav-bar"),
keys_to_strip={"children"},
)
assert_component_equal(built_navigation["nav-bar"], html.Div(id="nav-bar"), keys_to_strip={"children"})
assert_component_equal(
built_navigation["nav-panel"], html.Div(id="nav-panel", hidden=True), keys_to_strip={"children"}
)

0 comments on commit 356dc2d

Please sign in to comment.