Skip to content

Commit

Permalink
Export data and filter interaction action tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-qb committed Oct 27, 2023
1 parent 4f7e175 commit 4faa43e
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 61 deletions.
37 changes: 16 additions & 21 deletions vizro-core/tests/unit/vizro/actions/test_export_data_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,28 @@ def callback_context_export_data(request):
"active_cell": CallbackTriggerDict(
id="vizro_table",
property="active_cell",
value={'row': 0, 'column': 0, 'column_id': 'country'},
value={"row": 0, "column": 0, "column_id": "country"},
str_id="vizro_table",
triggered=False,
),
"derived_viewport_data": CallbackTriggerDict(
id="vizro_table",
property="derived_viewport_data",
value=[
{'country': 'Algeria', 'continent': 'Africa', 'year': 2007, 'lifeExp': 72.301, 'pop': 33333216,
'gdpPercap': 6223.367465, 'iso_alpha': 'DZA', 'iso_num': 12},
{'country': 'Egypt', 'continent': 'Africa', 'year': 2007, 'lifeExp': 71.33800000000002,
'pop': 80264543, 'gdpPercap': 5581.180998, 'iso_alpha': 'EGY', 'iso_num': 818},
{'country': 'South Africa', 'continent': 'Africa', 'year': 2007, 'lifeExp': 49.339,
'pop': 43997828,
'gdpPercap': 9269.657808, 'iso_alpha': 'ZAF', 'iso_num': 710}
{
"country": "Algeria",
"continent": "Africa",
"year": 2007,
},
{
"country": "Egypt",
"continent": "Africa",
"year": 2007,
},
],
str_id="vizro_table",
triggered=False,
)
),
}
)
mock_callback_context = {
Expand Down Expand Up @@ -219,9 +222,7 @@ def test_invalid_target(

@pytest.mark.usefixtures("managers_one_page_two_graphs_one_button")
@pytest.mark.parametrize(
"callback_context_export_data, "
"target_scatter_filter_and_filter_interaction, "
"target_box_filtered_pop",
"callback_context_export_data, " "target_scatter_filter_and_filter_interaction, " "target_box_filtered_pop",
[
(
[["scatter_chart", "box_chart"], [10**6, 10**7], None, None],
Expand Down Expand Up @@ -272,20 +273,14 @@ def test_multiple_targets_with_filter_and_filter_interaction(

@pytest.mark.usefixtures("managers_one_page_two_graphs_one_table_one_button")
@pytest.mark.parametrize(
"callback_context_export_data, "
"target_scatter_filter_and_filter_interaction, "
"target_box_filtered_pop",
"callback_context_export_data, " "target_scatter_filter_and_filter_interaction, " "target_box_filtered_pop",
[
(
[["scatter_chart", "box_chart"], [10**6, 10**7], None, "Algeria"],
[[10**6, 10**7], None, ["Algeria"]],
[10**6, 10**7],
),
(
[["scatter_chart", "box_chart"], None, "Africa", "Algeria"],
[None, ["Africa"], ["Algeria"]],
None
),
([["scatter_chart", "box_chart"], None, "Africa", "Algeria"], [None, ["Africa"], ["Algeria"]], None),
(
[["scatter_chart", "box_chart"], [10**6, 10**7], "Africa", "Algeria"],
[[10**6, 10**7], ["Africa"], ["Algeria"]],
Expand Down Expand Up @@ -330,4 +325,4 @@ def test_multiple_targets_with_filter_and_filter_interaction_and_table(
] == target_scatter_filter_and_filter_interaction.to_csv(index=False)

assert result["download-dataframe_box_chart"]["filename"] == "box_chart.csv"
assert result["download-dataframe_box_chart"]["content"] == target_box_filtered_pop.to_csv(index=False)
assert result["download-dataframe_box_chart"]["content"] == target_box_filtered_pop.to_csv(index=False)
Loading

0 comments on commit 4faa43e

Please sign in to comment.