From f5cba34ea07182a956d0844c2663d7a8579d7375 Mon Sep 17 00:00:00 2001 From: Sophie Pike Date: Fri, 14 Aug 2026 09:33:58 +0100 Subject: [PATCH 1/4] tests: complete unit and integration tests for all_runs attribute of Pipeline --- tests/test_pipeline.py | 305 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 304 insertions(+), 1 deletion(-) diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index e0a913e..6a7b8ff 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1180,7 +1180,7 @@ def test_last_run_most_recent_no_directory( assert pipeline.last_run.manifest.run_id == "run_older" -class TestLoadAllRunsIntegration(TestLoadLatestRunIntegration): +class TestLoadAllRunsUnitTests(TestLoadLatestRunIntegration): def test_returns_none_when_error_in_extract_historical_runs( self, monkeypatch, pipeline_no_history ) -> None: @@ -1498,3 +1498,306 @@ def test_none_if_all_stageloaderrors( result = pipeline_no_history._load_all_runs() assert result is None + assert pipeline_no_history.all_runs is None + + def test_success_run_no_errors( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that the pipeline correctly loads all historical runs without errors. + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised if there is an issue loading historical runs, which should not + happen in this test. + """ + mock_loader = mock.MagicMock( + side_effect=[mock.sentinel.run_A, mock.sentinel.run_B] + ) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + { + "run_id": "run_B", + "timestamp": "2026-08-10 10:01:00,000", + "run_dir": Path("/path/to/run_B"), + }, + ], + ) + + with warnings.catch_warnings(record=True) as w: + pipeline_no_history._load_all_runs() + + assert not any( + issubclass(warning.category, PipelineConfigurationWarning) for warning in w + ) + + def test_all_log_entries_invalid_ids( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that the pipeline returns None for all_runs when all historical + runs have an invalid run_id (either empty or None). + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when all historical runs have invalid run_ids, indicating that + the all_runs attribute will be None. + """ + mock_loader = mock.MagicMock(return_value=mock.sentinel) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + { + "run_id": None, + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + ], + ) + + with pytest.warns(PipelineConfigurationWarning): + result = pipeline_no_history._load_all_runs() + assert result is None + assert pipeline_no_history.all_runs is None + + def test_duplicate_run_ids_overwrite( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that when duplicate run_ids are found, the last one in the list + overwrites the previous one in the all_runs dictionary. + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when duplicate run_ids are found, indicating that the last one + will overwrite the previous one in the all_runs dictionary. + """ + mock_loader = mock.MagicMock( + side_effect=[mock.sentinel.first_loaded, mock.sentinel.second_loaded] + ) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/first_loaded"), + }, + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:01:00,000", + "run_dir": Path("/path/to/second_loaded"), + }, + ], + ) + + with warnings.catch_warnings(record=True) as w: + result = pipeline_no_history._load_all_runs() + + assert not any( + issubclass(warning.category, PipelineConfigurationWarning) for warning in w + ) + + assert result is not None + assert isinstance(result, dict) + assert len(result) == 1 + assert result["run_A"] is mock.sentinel.second_loaded + + +class TestLoadAllRunsIntegration(TestLoadLatestRunIntegration): + def test_all_runs_none_first_run(self, tmp_path: Path) -> None: + """ + Tests that when a Pipeline instance has no previous runs, the all_runs + attribute is None. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when no previous runs are found for the Pipeline, indicating + that the all_runs attribute will be None. + """ + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs"), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + pipeline.run_output = tmp_path / "runs" + assert pipeline.all_runs is None + + def test_all_runs_populated_multiple_runs( + self, tmp_path: Path, minimal_pipeline_yaml + ) -> None: + """ + Tests that when a Pipeline instance has multiple previous runs, the all_runs + attribute is populated with all historical runs. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + ``minimal_pipeline_yaml`` : callable + A fixture that returns a minimal YAML configuration for a historical run. + """ + + logs = tmp_path / "logs" + logs.mkdir(parents=True, exist_ok=True) + (logs / "onsrap.log").write_text( + "2026-08-11 10:00:00,000 Pipeline started | " + '{"run_id": "run_older", ' + ' "run_dir": "/path/to/run"}\n' + "2026-08-11 10:01:00,000 Pipeline started | " + '{"run_id": "run_newer", ' + ' "run_dir": "/path/to/run"}' + ) + + temp_attributes_1 = ( + tmp_path + / "outputs" + / "runs" + / "run_older" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_1.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_1.write_text( + minimal_pipeline_yaml(run_id="run_older"), encoding="utf-8" + ) + + temp_attributes_2 = ( + tmp_path + / "outputs" + / "runs" + / "run_newer" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_2.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_2.write_text( + minimal_pipeline_yaml(run_id="run_newer"), encoding="utf-8" + ) + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + + assert pipeline.all_runs is not None + assert pipeline.all_runs["run_newer"].manifest.run_id == "run_newer" + assert pipeline.all_runs["run_older"].manifest.run_id == "run_older" + assert len(pipeline.all_runs) == 2 + + def test_deleted_run_not_populated_all_runs( + self, tmp_path: Path, minimal_pipeline_yaml + ) -> None: + """ + Tests that when a Pipeline instance has multiple previous runs but one of those + runs have been deleted/removed, the all_runs attribute is populated only + with the existing historical runs. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + ``minimal_pipeline_yaml`` : callable + A fixture that returns a minimal YAML configuration for a historical run. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when there is no stages_to_run parameters to warn the user that + all stages will be run by default. + """ + + logs = tmp_path / "logs" + logs.mkdir(parents=True, exist_ok=True) + (logs / "onsrap.log").write_text( + "2026-08-11 10:00:00,000 Pipeline started | " + '{"run_id": "run_older", ' + ' "run_dir": "/path/to/run"}\n' + "2026-08-11 10:01:00,000 Pipeline started | " + '{"run_id": "run_newer", ' + ' "run_dir": "/path/to/run"}' + ) + + temp_attributes_1 = ( + tmp_path + / "outputs" + / "runs" + / "run_older" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_1.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_1.write_text( + minimal_pipeline_yaml(run_id="run_older"), encoding="utf-8" + ) + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + + assert pipeline.all_runs is not None + assert pipeline.all_runs["run_older"].manifest.run_id == "run_older" + assert len(pipeline.all_runs) == 1 From ec6151d900b0126633861512a9b57c3172e64ef9 Mon Sep 17 00:00:00 2001 From: Sophie Pike Date: Fri, 14 Aug 2026 09:33:58 +0100 Subject: [PATCH 2/4] tests: complete unit and integration tests for all_runs attribute of Pipeline --- tests/test_pipeline.py | 305 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 304 insertions(+), 1 deletion(-) diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 980bb97..ae9fa04 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1192,7 +1192,7 @@ def test_last_run_most_recent_no_directory( assert pipeline.last_run.manifest.run_id == "run_older" -class TestLoadAllRunsIntegration(TestLoadLatestRunIntegration): +class TestLoadAllRunsUnitTests(TestLoadLatestRunIntegration): def test_returns_none_when_error_in_extract_historical_runs( self, monkeypatch, pipeline_no_history ) -> None: @@ -1510,3 +1510,306 @@ def test_none_if_all_stageloaderrors( result = pipeline_no_history._load_all_runs() assert result is None + assert pipeline_no_history.all_runs is None + + def test_success_run_no_errors( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that the pipeline correctly loads all historical runs without errors. + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised if there is an issue loading historical runs, which should not + happen in this test. + """ + mock_loader = mock.MagicMock( + side_effect=[mock.sentinel.run_A, mock.sentinel.run_B] + ) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + { + "run_id": "run_B", + "timestamp": "2026-08-10 10:01:00,000", + "run_dir": Path("/path/to/run_B"), + }, + ], + ) + + with warnings.catch_warnings(record=True) as w: + pipeline_no_history._load_all_runs() + + assert not any( + issubclass(warning.category, PipelineConfigurationWarning) for warning in w + ) + + def test_all_log_entries_invalid_ids( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that the pipeline returns None for all_runs when all historical + runs have an invalid run_id (either empty or None). + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when all historical runs have invalid run_ids, indicating that + the all_runs attribute will be None. + """ + mock_loader = mock.MagicMock(return_value=mock.sentinel) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + { + "run_id": None, + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/run_A"), + }, + ], + ) + + with pytest.warns(PipelineConfigurationWarning): + result = pipeline_no_history._load_all_runs() + assert result is None + assert pipeline_no_history.all_runs is None + + def test_duplicate_run_ids_overwrite( + self, monkeypatch, pipeline_no_history: Pipeline + ) -> None: + """ + Asserts that when duplicate run_ids are found, the last one in the list + overwrites the previous one in the all_runs dictionary. + + Parameters + ---------- + ``monkeypatch`` : pytest.MonkeyPatch + A pytest fixture that allows for dynamic modification of attributes, + methods, or classes during testing. + ``pipeline_no_history`` : Pipeline + A Pipeline instance with no historical runs. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when duplicate run_ids are found, indicating that the last one + will overwrite the previous one in the all_runs dictionary. + """ + mock_loader = mock.MagicMock( + side_effect=[mock.sentinel.first_loaded, mock.sentinel.second_loaded] + ) + monkeypatch.setattr("onsrap.pipeline.load_historical_run", mock_loader) + + monkeypatch.setattr( + pipeline_no_history.logger, + "extract_historical_run_ids", + lambda x: [ + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:00:00,000", + "run_dir": Path("/path/to/first_loaded"), + }, + { + "run_id": "run_A", + "timestamp": "2026-08-10 10:01:00,000", + "run_dir": Path("/path/to/second_loaded"), + }, + ], + ) + + with warnings.catch_warnings(record=True) as w: + result = pipeline_no_history._load_all_runs() + + assert not any( + issubclass(warning.category, PipelineConfigurationWarning) for warning in w + ) + + assert result is not None + assert isinstance(result, dict) + assert len(result) == 1 + assert result["run_A"] is mock.sentinel.second_loaded + + +class TestLoadAllRunsIntegration(TestLoadLatestRunIntegration): + def test_all_runs_none_first_run(self, tmp_path: Path) -> None: + """ + Tests that when a Pipeline instance has no previous runs, the all_runs + attribute is None. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when no previous runs are found for the Pipeline, indicating + that the all_runs attribute will be None. + """ + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs"), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + pipeline.run_output = tmp_path / "runs" + assert pipeline.all_runs is None + + def test_all_runs_populated_multiple_runs( + self, tmp_path: Path, minimal_pipeline_yaml + ) -> None: + """ + Tests that when a Pipeline instance has multiple previous runs, the all_runs + attribute is populated with all historical runs. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + ``minimal_pipeline_yaml`` : callable + A fixture that returns a minimal YAML configuration for a historical run. + """ + + logs = tmp_path / "logs" + logs.mkdir(parents=True, exist_ok=True) + (logs / "onsrap.log").write_text( + "2026-08-11 10:00:00,000 Pipeline started | " + '{"run_id": "run_older", ' + ' "run_dir": "/path/to/run"}\n' + "2026-08-11 10:01:00,000 Pipeline started | " + '{"run_id": "run_newer", ' + ' "run_dir": "/path/to/run"}' + ) + + temp_attributes_1 = ( + tmp_path + / "outputs" + / "runs" + / "run_older" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_1.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_1.write_text( + minimal_pipeline_yaml(run_id="run_older"), encoding="utf-8" + ) + + temp_attributes_2 = ( + tmp_path + / "outputs" + / "runs" + / "run_newer" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_2.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_2.write_text( + minimal_pipeline_yaml(run_id="run_newer"), encoding="utf-8" + ) + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + + assert pipeline.all_runs is not None + assert pipeline.all_runs["run_newer"].manifest.run_id == "run_newer" + assert pipeline.all_runs["run_older"].manifest.run_id == "run_older" + assert len(pipeline.all_runs) == 2 + + def test_deleted_run_not_populated_all_runs( + self, tmp_path: Path, minimal_pipeline_yaml + ) -> None: + """ + Tests that when a Pipeline instance has multiple previous runs but one of those + runs have been deleted/removed, the all_runs attribute is populated only + with the existing historical runs. + + Parameters + ---------- + ``tmp_path`` : Path + A temporary directory provided by pytest for creating test files + and directories. + ``minimal_pipeline_yaml`` : callable + A fixture that returns a minimal YAML configuration for a historical run. + + Raises + ------ + ``PipelineConfigurationWarning`` + Raised when there is no stages_to_run parameters to warn the user that + all stages will be run by default. + """ + + logs = tmp_path / "logs" + logs.mkdir(parents=True, exist_ok=True) + (logs / "onsrap.log").write_text( + "2026-08-11 10:00:00,000 Pipeline started | " + '{"run_id": "run_older", ' + ' "run_dir": "/path/to/run"}\n' + "2026-08-11 10:01:00,000 Pipeline started | " + '{"run_id": "run_newer", ' + ' "run_dir": "/path/to/run"}' + ) + + temp_attributes_1 = ( + tmp_path + / "outputs" + / "runs" + / "run_older" + / "pipeline_attributes_for_test.yaml" + ) + temp_attributes_1.parent.mkdir(parents=True, exist_ok=True) + temp_attributes_1.write_text( + minimal_pipeline_yaml(run_id="run_older"), encoding="utf-8" + ) + + with pytest.warns(PipelineConfigurationWarning): + pipeline = Pipeline( + config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), + stages=[ + Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) + ], + ) + + assert pipeline.all_runs is not None + assert pipeline.all_runs["run_older"].manifest.run_id == "run_older" + assert len(pipeline.all_runs) == 1 From 29e24d7018c5b125001b9aa905de2a7a9b7d4ee1 Mon Sep 17 00:00:00 2001 From: Sophie Pike Date: Tue, 18 Aug 2026 10:35:07 +0100 Subject: [PATCH 3/4] test: correct tests for all_runs given changes to extract_historical_run_ids --- examples/pipeline_2/outputs/order_analysis.md | 2 +- tests/test_pipeline.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/pipeline_2/outputs/order_analysis.md b/examples/pipeline_2/outputs/order_analysis.md index d1ea234..58e2372 100644 --- a/examples/pipeline_2/outputs/order_analysis.md +++ b/examples/pipeline_2/outputs/order_analysis.md @@ -26,7 +26,7 @@ Lowest profit: **Pen** at **£-1.90** ## Order Analysis -The most orders occured on a **Tuesday**. +The most orders occured on a **Monday**. **2** order/s were Large (greater than 75% of orders for the period). diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index ae9fa04..701d535 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1540,7 +1540,7 @@ def test_success_run_no_errors( monkeypatch.setattr( pipeline_no_history.logger, "extract_historical_run_ids", - lambda x: [ + lambda x, y: [ { "run_id": "run_A", "timestamp": "2026-08-10 10:00:00,000", @@ -1588,7 +1588,7 @@ def test_all_log_entries_invalid_ids( monkeypatch.setattr( pipeline_no_history.logger, "extract_historical_run_ids", - lambda x: [ + lambda x, y: [ { "run_id": "", "timestamp": "2026-08-10 10:00:00,000", @@ -1636,7 +1636,7 @@ def test_duplicate_run_ids_overwrite( monkeypatch.setattr( pipeline_no_history.logger, "extract_historical_run_ids", - lambda x: [ + lambda x, y: [ { "run_id": "run_A", "timestamp": "2026-08-10 10:00:00,000", @@ -1684,6 +1684,7 @@ def test_all_runs_none_first_run(self, tmp_path: Path) -> None: with pytest.warns(PipelineConfigurationWarning): pipeline = Pipeline( + name="test_pipeline", config=PipelineConfig(output_dir=tmp_path / "outputs"), stages=[ Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) @@ -1713,9 +1714,11 @@ def test_all_runs_populated_multiple_runs( (logs / "onsrap.log").write_text( "2026-08-11 10:00:00,000 Pipeline started | " '{"run_id": "run_older", ' + ' "name": "test_pipeline",' ' "run_dir": "/path/to/run"}\n' "2026-08-11 10:01:00,000 Pipeline started | " '{"run_id": "run_newer", ' + ' "name": "test_pipeline",' ' "run_dir": "/path/to/run"}' ) @@ -1745,6 +1748,7 @@ def test_all_runs_populated_multiple_runs( with pytest.warns(PipelineConfigurationWarning): pipeline = Pipeline( + name="test_pipeline", config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), stages=[ Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) @@ -1784,9 +1788,11 @@ def test_deleted_run_not_populated_all_runs( (logs / "onsrap.log").write_text( "2026-08-11 10:00:00,000 Pipeline started | " '{"run_id": "run_older", ' + '"name": "test_pipeline",' ' "run_dir": "/path/to/run"}\n' "2026-08-11 10:01:00,000 Pipeline started | " '{"run_id": "run_newer", ' + '"name": "test_pipeline",' ' "run_dir": "/path/to/run"}' ) @@ -1804,6 +1810,7 @@ def test_deleted_run_not_populated_all_runs( with pytest.warns(PipelineConfigurationWarning): pipeline = Pipeline( + name="test_pipeline", config=PipelineConfig(output_dir=tmp_path / "outputs", log_dir=logs), stages=[ Stage("Stage_0", source=tmp_path / "Stage_0.py", dependencies=()) From 86191f19c46ec24257667b9ffe67a66e49207d2f Mon Sep 17 00:00:00 2001 From: Sophie Pike_ONS <133784265+pikes-ons@users.noreply.github.com> Date: Tue, 18 Aug 2026 11:05:44 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- examples/pipeline_2/outputs/order_analysis.md | 2 +- tests/test_pipeline.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/pipeline_2/outputs/order_analysis.md b/examples/pipeline_2/outputs/order_analysis.md index 58e2372..9079926 100644 --- a/examples/pipeline_2/outputs/order_analysis.md +++ b/examples/pipeline_2/outputs/order_analysis.md @@ -26,7 +26,7 @@ Lowest profit: **Pen** at **£-1.90** ## Order Analysis -The most orders occured on a **Monday**. +The most orders occurred on a **Monday**. **2** order/s were Large (greater than 75% of orders for the period). diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 701d535..fa7fbed 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1555,12 +1555,13 @@ def test_success_run_no_errors( ) with warnings.catch_warnings(record=True) as w: - pipeline_no_history._load_all_runs() + result = pipeline_no_history._load_all_runs() assert not any( issubclass(warning.category, PipelineConfigurationWarning) for warning in w ) - + assert result == {"run_A": mock.sentinel.run_A, "run_B": mock.sentinel.run_B} + assert mock_loader.call_count == 2 def test_all_log_entries_invalid_ids( self, monkeypatch, pipeline_no_history: Pipeline ) -> None: