From b755efa4db160a5ca45f8517e11e048db5c6dcd7 Mon Sep 17 00:00:00 2001 From: AdamZh0u Date: Tue, 17 Dec 2024 00:21:30 +0000 Subject: [PATCH] fix test context --- tests/test_GeoJupyterViz.py | 50 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/test_GeoJupyterViz.py b/tests/test_GeoJupyterViz.py index 1a646475..caec5ca6 100644 --- a/tests/test_GeoJupyterViz.py +++ b/tests/test_GeoJupyterViz.py @@ -60,27 +60,31 @@ def test_card_function( @patch("mesa_geo.visualization.geojupyter_viz.jv.ModelController") @patch("mesa_geo.visualization.geojupyter_viz.jv.UserInputs") @patch("mesa_geo.visualization.geojupyter_viz.jv.split_model_params") + @patch("mesa_geo.visualization.geojupyter_viz.jv.make_initial_grid_layout") @patch("mesa_geo.visualization.geojupyter_viz.solara.use_memo") @patch("mesa_geo.visualization.geojupyter_viz.solara.use_reactive") @patch("mesa_geo.visualization.geojupyter_viz.solara.use_state") @patch("mesa_geo.visualization.geojupyter_viz.solara.AppBarTitle") @patch("mesa_geo.visualization.geojupyter_viz.solara.AppBar") @patch("mesa_geo.visualization.geojupyter_viz.leaflet_viz.MapModule") + @patch("mesa_geo.visualization.geojupyter_viz.rv.Card") def test_geojupyterviz_function( self, - mock_MapModule, # noqa: N803 - mock_AppBar, # noqa: N803 - mock_AppBarTitle, # noqa: N803 + mock_rv_Card, + mock_MapModule, + mock_AppBar, + mock_AppBarTitle, mock_use_state, mock_use_reactive, mock_use_memo, + mock_make_initial_grid_layout, mock_split_model_params, - mock_UserInputs, # noqa: N803 - mock_ModelController, # noqa: N803 - mock_Markdown, # noqa: N803 - mock_Card, # noqa: N803 - mock_Sidebar, # noqa: N803 - mock_GridDraggable, # noqa: N803 + mock_UserInputs, + mock_ModelController, + mock_Markdown, + mock_Card, + mock_Sidebar, + mock_GridDraggable, ): model_class = MagicMock() model_params = MagicMock() @@ -96,20 +100,22 @@ def test_geojupyterviz_function( mock_split_model_params.return_value = ({}, {}) mock_use_state.return_value = ({}, MagicMock()) mock_use_memo.return_value = MagicMock() + mock_make_initial_grid_layout.return_value = {} + + mock_rv_Card.return_value.__enter__ = MagicMock() + mock_rv_Card.return_value.__exit__ = MagicMock() - solara.render( - GeoJupyterViz( - model_class=model_class, - model_params=model_params, - measures=measures, - name=name, - agent_portrayal=agent_portrayal, - play_interval=play_interval, - view=view, - zoom=zoom, - center_point=center_point, - ) - ) + solara.render(GeoJupyterViz( + model_class=model_class, + model_params=model_params, + measures=measures, + name=name, + agent_portrayal=agent_portrayal, + play_interval=play_interval, + view=view, + zoom=zoom, + center_point=center_point, + )) mock_AppBar.assert_called_once() mock_AppBarTitle.assert_called_once_with(name)