Skip to Content

Repository tests

tests/ contains tests of _pmiconfig tools and operational safety contracts. It is distinct from ../testkit/, which provides reusable testing infrastructure for Odoo addon repositories.

Test groups

  • test_update_addons_path.py verifies selective multiline config updates, byte preservation, preview, symlinks, metadata, refusals, and publication failure using synthetic files only.

  • test_shared_config.sh verifies the external registry default, explicit config precedence, empty generic template, and missing-configuration behavior. Backup and restore tests use fixtures/pmiverse.conf and temporary synthetic registries; they do not require the installation's _pmiregistry checkout.

  • test_reset_admin_password.py verifies user ID 2 recovery, optional activation, private generated passwords, refusals, and transaction failures with Odoo doubles.

  • test_create_database.py verifies new-database provisioning, secure password input, collisions, module-state checks, and partial failure using synthetic Odoo doubles. No Odoo runtime or PostgreSQL connection is used.

  • test_script_cli.py inventories every runnable scripts/ command and verifies safe -h/--help, completion option coverage, path registrations, value suggestions, stale ./basename handler replacement, and idempotent user completion installation. It requires Linux Bubblewrap (bwrap) with usable namespaces; a missing binary skips these checks, while a namespace failure fails them. The sandbox hides live configuration, blocks network access, makes host files read-only, and exposes only the harmless tools required for help. Sourced Bash libraries and SQL maintenance input are excluded from the CLI inventory.

  • test_enhanced_update18_catalog.py verifies translation-repository catalog selection, clone/update paths, and Git failure handling with mocked commands.
  • test_translation_deploy.py verifies automatic translation deployment in both Odoo 18 updaters, dependency ordering, target matching, skips, and failure exit statuses using temporary configuration and mocked operational commands.
  • test_update_pot_repo.py verifies catalog folder selection, invalid input refusals, non-operational repository listing, and shared Bash completion without database exports.
  • test_fetch_requirements.py verifies runtime requirement discovery, recursive includes, exclusions, deduplication, version constraints, and output generation.
  • test_pmiverse_odoo_addons.py verifies the reusable pytest namespace plugin.
  • test_backup_locking.sh exercises backup publication and locking contracts with isolated fixtures.
  • test_backup_registry.sh verifies instance/database selection, dry-run, invalid configuration refusals, PostgreSQL overrides, host-scoped publication, partial failure, path isolation, per-database retention, and nested-source laptop restore with mocks.
  • test_backup_follow.sh verifies service start, journal following, result propagation, active-run attachment, and signal cleanup with isolated mocks.
  • test_restore_safety.sh exercises restore validation, locking, publication, rollback, and signal-safety contracts with its test harness.
  • test_restore_config_library.sh, test_restore_archive_library.sh, test_restore_postgresql_library.sh, test_restore_neutralization_library.sh, and test_restore_publication_library.sh own the five restore-library boundaries.
  • test_restore_cli_contract.sh verifies public loading, argument, dry-run, direct, cross-working-directory, symlink, and missing-library behavior.
  • Database-specific source-selection and CLI tests live in the owning _pmiregistry/tests/ directory.
  • test_restore_docs_completion.sh verifies the durable restore architecture, modes, documentation navigation, and legacy-command classification.
  • test_integration_layout.sh verifies the host-integration helper layout, command modes and syntax, placeholder contract, and removed-path references.
  • test_testkit_layout.sh verifies the authoritative reusable asset tree, active source-path consumers, scaffold destination names, and cross-repository stale-path protection.
  • test_pytest_repo_parallel.sh verifies rolling addon scheduling, concurrency limits, completion draining, and failure counting with isolated shell workers.
  • test_pytest_repo_keep_db.sh verifies database retention on success and failure, default cleanup, and runner/pytest argument separation using mocked databases and the addon runner's actual cleanup policy.
  • test_pytest_addon_dependencies.sh verifies automatic test-app installation, unchanged addon-only runs, invalid declaration and database refusal before writes, and installation-failure cleanup using a fully mocked runner environment.
  • test_ruff_policy.py verifies canonical Ruff import ordering, Ruff-only shared consumers, non-writing checks, idempotent fixes, and semantic policy synchronization.

Python bytecode, __pycache__/, and .pytest_cache/ are generated local state and are ignored. They do not belong in source control.

Static inspections

The repository .shellcheckrc enables analysis of sourced libraries and resolves source hints relative to each script. Runtime-selected virtualenv activation and generated fixture code use /dev/null hints because their source is not checked in. Statement- or function-scoped directives retain intentional glob matching, literal shell text in assertions and injection fixtures, caller-owned output variables, and trap callbacks that ShellCheck cannot trace. These directives do not disable the corresponding inspections repository-wide.

The catalog test uses statement-scoped PyCharm annotations for monkeypatch targets on a dynamically imported module and an inherited standard-library method. Pytest's default raising=True still verifies that every patched attribute exists.

Running tests

Creation and administrator recovery share runtime/password helpers. Their implementation guide provides the combined focused command and explains what mocked acceptance does and does not prove.

There is no checked-in all-tests wrapper for this directory. Select the smallest relevant test and inspect its fixtures before running it. The shell tests are integration-style harnesses around operational scripts; do not replace their isolated fixtures with live databases, filestores, backup trees, or deployed instances. Follow the canonical PMIVerse testing policy and the repository's documentation portal. The restore-specific ownership map is in the restore architecture contract.

The standalone repository-catalog test does not need Odoo plugins. Run it with the configured interpreter, disabling third-party plugin autoload:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /srv/pmiverse/_pmisuite18/venv/bin/python \
  -m pytest tests/test_enhanced_update18_catalog.py tests/test_translation_deploy.py \
  -q -p no:cacheprovider