message_ix_models.tests.model.test_bmt

Tests for the BMT workflow (Buildings, Materials, Transport).

Covers message_ix_models.model.bmt.workflow and linked sector builds:

Coverage notes: - prepare_data_B and build_B: tested with and without materials

(with_materials=False and with_materials=True in test_prepare_data_B_*, test_build_B_runs_with_minimal_data, test_build_B_runs_with_materials).

  • utils: build_PM (test_build_PM_*), _generate_vetting_csv (test_generate_vetting_csv*).

  • CLI: bmt group and run subcommand (test_bmt_cli_help, test_bmt_run_dry_run).

  • Common workflow step functions: _set_as_default, prep_for_macro, add_macro.

Functions

bmt_context(test_context, tmp_path)

BMT context (R12) and buildings config with paths to minimal CSVs.

bmt_context_with_materials(bmt_context)

Like bmt_context but with with_materials=True for build_B materials path.

test_add_macro(capfd, monkeypatch, request, ...)

add_macro() uses the configured file and solves with MESSAGE-MACRO.

test_bmt_cli_help(mix_models_cli)

bmt and bmt run show --help.

test_bmt_run_dry_run(mix_models_cli)

bmt run --dry-run TARGET runs workflow in dry-run (writes SVG, no execution).

test_bmt_workflow_has_bmtx_built_step(...)

The BMT workflow includes the 'BMTX built' step that calls build_PM.

test_bmt_workflow_has_mt_and_bmt_built_steps(...)

The BMT workflow includes MT built and BMT built steps.

test_build_PM_callable(test_context, request)

build_PM(context, scenario) runs; skip if scenario lacks inv_cost.

test_build_PM_returns_scenario(test_context, ...)

build_PM returns the scenario when power-sector material data already exists.

test_generate_vetting_csv(tmp_path)

generate_vetting_csv writes CSV of original/modified demand and subtraction.

test_generate_vetting_csv_zero_original(tmp_path)

generate_vetting_csv handles zeros in original_demand.

test_prep_for_macro(test_context, request, ...)

prep_for_macro removes macro sectors and calls solve.

test_set_as_default(test_context, request)

_set_as_default sets the scenario as default and returns it.