From 1247392a3dfb9c87bdd6825af000f81cdd651792 Mon Sep 17 00:00:00 2001 From: Chuck McCallum Date: Thu, 7 Nov 2024 16:31:05 -0500 Subject: [PATCH] do not clean up values --- dp_creator_ii/app/analysis_panel.py | 6 +++--- tests/test_app.py | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dp_creator_ii/app/analysis_panel.py b/dp_creator_ii/app/analysis_panel.py index 7d6fdad..b4f241d 100644 --- a/dp_creator_ii/app/analysis_panel.py +++ b/dp_creator_ii/app/analysis_panel.py @@ -71,9 +71,9 @@ def _update_checkbox_group(): @reactive.event(input.columns_checkbox_group) def _on_column_set_change(): column_ids_selected = input.columns_checkbox_group() - _cleanup_reactive_dict(lower_bounds, column_ids_selected) - _cleanup_reactive_dict(upper_bounds, column_ids_selected) - _cleanup_reactive_dict(bin_counts, column_ids_selected) + # We only clean up the weights, and everything else is left in place, + # so if you restore a column, you see the original values. + # (Except for weight, which goes back to the default.) _cleanup_reactive_dict(weights, column_ids_selected) @render.ui diff --git a/tests/test_app.py b/tests/test_app.py index 624b276..379941b 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -9,6 +9,7 @@ default_app = create_app_fixture(Path(__file__).parent / "fixtures/default_app.py") tooltip = "#choose_csv_demo_tooltip_ui svg" for_the_demo = "For the demo, we'll imagine" +simulation = "This simulation assumes a normal distribution" # TODO: Why is incomplete coverage reported here? @@ -84,16 +85,23 @@ def expect_no_error(): # Set column details: page.get_by_label("grade").check() - page.get_by_label("Min").click() - page.get_by_label("Min").fill("0") - # TODO: All these recalculations cause timeouts: + expect_visible(simulation) + # Check that default is set correctly: + assert page.get_by_label("Max").input_value() == "10" + # Reset, and confirm: + new_value = "20" + page.get_by_label("Max").fill(new_value) + # Uncheck the column: + page.get_by_label("grade").uncheck() + expect_not_visible(simulation) + # Recheck the column: + page.get_by_label("grade").check() + expect_visible(simulation) + assert page.get_by_label("Max").input_value() == new_value + # TODO: Setting more inputs without checking for updates + # cause recalculations to pile up, and these cause timeouts on CI: # It is still rerendering the graph after hitting "Download results". # https://github.com/opendp/dp-creator-ii/issues/116 - # page.get_by_label("Max").click() - # page.get_by_label("Max").fill("100") - # page.get_by_label("Bins").click() - # page.get_by_label("Bins").fill("20") - page.get_by_label("Weight").select_option("1") expect_no_error() # -- Download results --