autowisp.tests.test_error_persistence module

Class Inheritance Diagram

Inheritance diagram of Error, FileKind, FindStarsError, Image, MasterFile, Path, PipelineRun, RelatedFile, SimpleNamespace, TestCleanupErrors, TestParseDuration, TestPersistError, TestRunPipelineHandler, _PersistenceTestCase, datetime, timedelta, timezone

Unit tests for error persistence (row + JSON sidecar).

These need a real (throwaway) project database, created once per class in a temporary directory.

class autowisp.tests.test_error_persistence.TestCleanupErrors(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_error_persistence.TestCleanupErrors

wisp-cleanup-errors prunes aged rows, orphan files, dangling rows.

Uses a fresh project per test, since cleanup mutates global DB state.

_age_error(error_id, *, days)[source]

Backdate an error’s created so it counts as old.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_aged_rows_and_sidecars_removed()[source]

An old error and its sidecar are deleted; a recent one is kept.

test_dangling_row_reference_cleared()[source]

A row whose sidecar vanished keeps the row but clears the path.

test_delete_all_sidecars_keeps_foreign_files()[source]

Project-deletion sidecar purge removes tracked files only.

Every recorded error’s sidecar is removed, but an unrelated file placed under the errors directory survives.

test_orphan_files_removed()[source]

A stray file with no owning row is swept away.

test_sweep_keeps_valid_sidecar()[source]

A healthy error’s sidecar is not touched by a plain sweep.

class autowisp.tests.test_error_persistence.TestParseDuration(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_error_persistence.TestParseDuration

parse_duration accepts compact durations and rejects junk.

test_invalid_raises()[source]
test_units()[source]
class autowisp.tests.test_error_persistence.TestPersistError(methodName='runTest')[source]

Bases: _PersistenceTestCase

Inheritance diagram of autowisp.tests.test_error_persistence.TestPersistError

persist_error writes the queryable row and the detail sidecar.

A related file matching a known image/master sets the FK.

test_delete_missing_error_is_noop()[source]

Deleting a non-existent error returns False, does not raise.

test_delete_removes_row_and_sidecar()[source]

delete_error removes both the row and its sidecar file.

test_large_payload_is_gzipped()[source]

A payload over the threshold is written as .json.gz and reloads.

test_missing_sidecar_degrades_to_none()[source]

Reading an error whose sidecar is gone returns None, no crash.

test_row_and_sidecar_are_complementary()[source]

Inline fields on the row; the heavy remainder in the sidecar.

test_sidecar_failure_leaves_valid_row()[source]

A sidecar-write failure still leaves a row, sidecar_path NULL.

test_worker_crashed_persists_step_name()[source]

A synthesised worker-death error lands its step on the row.

End-to-end regression for the crash-report “no matching logs found” gap: a WorkerCrashedError is synthesised by the parent (so it is not a per-stage StepError subclass), but it must still persist step_name into the queryable column – that is what crash-report log-collection resolves the run/step logs from. It is a step-component error because the failure is in the algorithm running inside the step.

class autowisp.tests.test_error_persistence.TestRunPipelineHandler(methodName='runTest')[source]

Bases: _PersistenceTestCase

Inheritance diagram of autowisp.tests.test_error_persistence.TestRunPipelineHandler

run_pipeline.main records an escaping error and re-raises it.

test_handler_persists_and_reraises()[source]

An AutoWISPError out of the run is persisted, then re-raised.

test_handler_records_plain_exception()[source]

A non-AutoWISP exception is recorded; the original re-raises.

Mirrors a real failure: a bad config expression raises a plain NameError in the orchestration layer, outside any step’s capture boundary. The handler records it (wrapped as a PipelineError) but re-raises the original so its true traceback reaches the log.

class autowisp.tests.test_error_persistence._PersistenceTestCase(methodName='runTest')[source]

Bases: TestCase

Base creating one throwaway project database for the class.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.