From 661d21599ccb8ca8e50aa80c375af3e1ac7917f0 Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Mon, 27 Jul 2026 10:54:56 -0700 Subject: [PATCH] Don't remove previous deployments from the quick_look_plots.html file. Add a test to find this regression. --- src/data/lrauv_deployment_plots.py | 4 --- src/data/test_lrauv_deployment_plots.py | 42 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index dc9bce4..d4648e5 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -528,10 +528,6 @@ def _update_index_html( content = index_path.read_text() all_hrefs = set(re.findall(r'href="([^"#][^"]*\.html)"', content)) group_names = dict(re.findall(r'

([^<]+)

', content)) - # Drop hrefs whose filename has a prefix before the group name (old auv_name_ style). - all_hrefs = { - h for h in all_hrefs if "/" not in h or Path(h).name.startswith(h.split("/")[0]) - } # clobber=True drops only this deployment's existing entries so they are rebuilt; # other deployments' entries are always preserved. known_hrefs = ( diff --git a/src/data/test_lrauv_deployment_plots.py b/src/data/test_lrauv_deployment_plots.py index e07a6f8..218baf1 100644 --- a/src/data/test_lrauv_deployment_plots.py +++ b/src/data/test_lrauv_deployment_plots.py @@ -415,6 +415,48 @@ def test_missing_png_produces_no_html(self, dp, tmp_path): assert not (tmp_path / "ghost.html").exists() # noqa: S101 +class TestUpdateIndexHtml: + """Regression tests for quick_look_plots.html accumulating multiple deployments. + + a3f4b45 ("Drop suffix from all the file names.") added a filter + intended to purge leftover old auv_name-prefixed hrefs when re-reading an + existing index, but it compared the href's filename against the date-range + dlist_dir instead of the old auv_name prefix. Since filenames are built from + the deployment name (not the dlist_dir), the filter matched nothing on + re-read and silently dropped every previously recorded deployment's entries. + """ + + def test_preserves_prior_deployments_across_calls(self, dp, tmp_path): + """A second deployment's _update_index_html() call must not erase the + first deployment's entries.""" + year_dir = tmp_path / "2025" + depl_dir_1 = year_dir / "20250414_20250418" + depl_dir_2 = year_dir / "20250501_20250505" + depl_dir_1.mkdir(parents=True) + depl_dir_2.mkdir(parents=True) + + dp._update_index_html( + depl_dir_1, + [depl_dir_1 / "CANON_April_2025_2column_cmocean.html"], + deployment_name="CANON April 2025", + ) + dp._update_index_html( + depl_dir_2, + [depl_dir_2 / "CANON_May_2025_2column_cmocean.html"], + deployment_name="CANON May 2025", + ) + + content = (year_dir / "quick_look_plots.html").read_text() + assert ( # noqa: S101 + 'href="20250414_20250418/CANON_April_2025_2column_cmocean.html"' in content + ) + assert ( # noqa: S101 + 'href="20250501_20250505/CANON_May_2025_2column_cmocean.html"' in content + ) + assert "CANON April 2025" in content # noqa: S101 + assert "CANON May 2025" in content # noqa: S101 + + # --------------------------------------------------------------------------- # Tests for plot_deployment() — exercises the stoqs_url_from_ds call path # ---------------------------------------------------------------------------