Follow-up to the packaging refactor (moving api/, web/, static/, main.py under src/fafycat/; introducing src/fafycat/cli.py as the unified entry point; switching AppConfig defaults to platformdirs).
The test suite was hardened ahead of the refactor so it can serve as a safety net. Once the refactor lands, a small set of cleanup tasks flips the suite from "works on both sides" to "post-refactor-native."
Checklist
1. Flip the TOUCHPOINT imports in tests/conftest.py
Change the five right-hand strings in the importlib.import_module(...) block:
2. Remove the sys.path bootstrap
3. Simplify the tmp_data_dir fixture
Once AppConfig derives DB URL, model_dir, and export_dir from FAFYCAT_DATA_DIR, drop the defensive per-leaf env vars:
4. Simplify _get_cli_module()
5. Add the post-refactor-only AppConfig default test
6. Add package entry-point tests
New file tests/test_package_entry_points.py with:
7. Follow-up brittleness (not blocking the refactor, but worth addressing while the suite is fresh)
Acceptance
uv run pytest stays green with the full refactor + all post-refactor cleanup applied.
- The refactor's parity tests (
tests/test_app_factory.py, tests/test_static_serving.py, tests/test_cli.py, tests/test_app_config.py) still pass.
rg 'src\\.fafycat|from main import|from api\\.|from web\\.' tests/ returns zero hits.
Follow-up to the packaging refactor (moving
api/,web/,static/,main.pyundersrc/fafycat/; introducingsrc/fafycat/cli.pyas the unified entry point; switchingAppConfigdefaults toplatformdirs).The test suite was hardened ahead of the refactor so it can serve as a safety net. Once the refactor lands, a small set of cleanup tasks flips the suite from "works on both sides" to "post-refactor-native."
Checklist
1. Flip the TOUCHPOINT imports in
tests/conftest.pyChange the five right-hand strings in the
importlib.import_module(...)block:\"src.fafycat.core.database\"→\"fafycat.core.database\"\"src.fafycat.core.config\"→\"fafycat.core.config\"\"main\"→\"fafycat.app\"\"api.dependencies\"→\"fafycat.api.dependencies\"\"api.ml\"→\"fafycat.api.ml\"2. Remove the
sys.pathbootstrapsys.path.insert(0, str(_SRC))/sys.path.insert(0, str(_ROOT))block at the top oftests/conftest.py(uv sync+ editable install makesfafycatimportable directly)._SRC/_ROOTreferences incli_runner'sPYTHONPATHassembly — the subprocess should pick upfafycatfrom the installed venv.sys.path.inserthacks still present in individual test modules (e.g.tests/test_ml_endpoints_simple.pypreviously had one; audit withrg 'sys\\.path\\.insert' tests/).3. Simplify the
tmp_data_dirfixtureOnce
AppConfigderivesDB URL,model_dir, andexport_dirfromFAFYCAT_DATA_DIR, drop the defensive per-leaf env vars:monkeypatch.setenv(\"FAFYCAT_DATA_DIR\", ...)only.FAFYCAT_DB_URL,FAFYCAT_MODEL_DIR,FAFYCAT_EXPORT_DIRsets.tests/test_app_config.pystill passes.4. Simplify
_get_cli_module()tests/conftest.py; hardcodereturn \"fafycat\".5. Add the post-refactor-only AppConfig default test
tests/test_app_config.py, addtest_data_dir_defaults_to_platformdirs_when_env_unset: unset everyFAFYCAT_*env var viamonkeypatch.delenv, instantiateAppConfig, assertstr(cfg.data_dir) == platformdirs.user_data_dir(\"fafycat\").6. Add package entry-point tests
New file
tests/test_package_entry_points.pywith:test_fafycat_app_importable—from fafycat.app import app, create_appsucceeds.test_fafycat_cli_importable—from fafycat.cli import mainsucceeds.test_python_m_fafycat_runs—cli_runner(\"--help\")exits 0 (the_get_cli_module()shim already resolves tofafycatpost-refactor).7. Follow-up brittleness (not blocking the refactor, but worth addressing while the suite is fresh)
tests/test_analytics_api.py(2023/2024 fixtures) andtests/test_api_automation.py(date(2025, 6, 15)) will silently rot as the current year advances. Parameterize or derive fromdate.today().tests/test_ml_status_ui.pyglobally patchespathlib.Path.exists. Scope to a specific path to avoid cross-contamination.tests_js/isn't wired into CI or annpm testscript. Either wire it up or remove if unused.Acceptance
uv run pyteststays green with the full refactor + all post-refactor cleanup applied.tests/test_app_factory.py,tests/test_static_serving.py,tests/test_cli.py,tests/test_app_config.py) still pass.rg 'src\\.fafycat|from main import|from api\\.|from web\\.' tests/returns zero hits.