Ensure tool_data_path exists; assert non-DM skip via persisted XML

install_tool_data_tables used to create tool_data_path as a side effect
of os.makedirs(target_dir); skipping it for non-DM repos means
copy_sample_files now blows up with FileNotFoundError. Explicitly
mkdir(exist_ok=True) before copying.

The non-DM integration test was asserting against the in-memory
tool_data_tables dict, which is populated as tools are loaded
regardless of registration; switch to verify_no_installed_repository_data_table_entries,
which inspects shed_tool_data_table_conf.xml.
This commit is contained in:
Nate Coraor
2026-05-13 17:08:03 -04:00
parent a5deee57ac
commit 07c5d445da
2 changed files with 7 additions and 3 deletions
@@ -188,6 +188,8 @@ class InstallRepositoryManager:
sample_files = irmm_metadata_dict.get("sample_files", [])
tool_index_sample_files = stdtm.get_tool_index_sample_files(sample_files)
tool_data_path = self.app.config.tool_data_path
# Used to be created as a side effect of install_tool_data_tables; that no longer runs for non-DM repos.
os.makedirs(tool_data_path, exist_ok=True)
tool_util.copy_sample_files(tool_data_path, tool_index_sample_files, tool_path=tool_path)
sample_files_copied = [str(s) for s in tool_index_sample_files]
repository_tools_tups = irmm.get_repository_tools_tups()
@@ -1,4 +1,5 @@
import os
import xml.etree.ElementTree as ET
from collections import namedtuple
from sqlalchemy import select
@@ -62,13 +63,14 @@ class TestRepositoryInstallIntegrationTestCase(integration_util.IntegrationTestC
self.uninstall_repository(*repo)
def test_non_data_manager_install_skips_data_table_registration(self):
"""Non-Data-Manager repos must not register data tables on install."""
"""Non-Data-Manager repos must not persist data table entries in shed_tool_data_table_conf.xml."""
non_dm_repo = ("devteam", "bwa", "051eba708f43")
non_dm_table_names = {"bwa_indexes", "bwa_mem_indexes"}
self.install_repository(*non_dm_repo)
registered = set(self._app.tool_data_tables.data_tables.keys())
shed_conf = self._app.config.shed_tool_data_table_config
registered = {t.get("name") for t in ET.parse(shed_conf).getroot().findall("table")}
leaked = non_dm_table_names & registered
assert not leaked, f"Unexpected data tables registered by non-DM repo: {sorted(leaked)}"
assert not leaked, f"Unexpected data tables in {shed_conf}: {sorted(leaked)}"
def test_repository_update(self):
response = self._install_repository(revision=REVISION_4, version="0.0.3", allow_upgraded=True)[0]