Skip to content

Simplify/refactor the CoDICE unit-test suite #3304

@sapols

Description

@sapols

Goal

Simplify the CoDICE unit-test suite. The current tests are highly coupled and complex, which makes them hard for future contributors to work with and extend. This was requested by Tenzin, and the work is unit-test-only — no changes to processing code.

Why now

Recent test-data churn (issues #3242 / #3251 / #3262) surfaced how brittle and coupled these tests are. A concrete example uncovered while working #3262: imap_processing/tests/codice/conftest.py's codice_lut_path _side_effect is inconsistent about validation dates — 8 L0 paths are built from the VALIDATION_FILE_DATE constant while 5 are hardcoded (conftest.py:110, 119, 128, 137, 146). That kind of split forces error-prone manual edits every time the validation epoch is rev'd, and is a symptom of broader coupling in the fixtures. #3262 does only the minimal correction; the deeper cleanup belongs here.

Ideas from Tenzin

Captured so we don't lose them. Tenzin explicitly encouraged starting fresh with a new look rather than treating these as a fixed checklist — a clean redesign may benefit contributors more.

  • Take in Joey's L0 file, process up to L1A or L1B or L2 and compare with Joey's then. E.g. if a product only gets processed up to L1B, then process L0 → L1B directly and compare with Joey's at L1B. Ignore intermediate levels in tests. Same for others: if a product only goes up to L2, process L0 → L2 and compare with L2. This gives us intermediate-product correctness along the path "for free."
  • If it's easier to use L0 data from the SDC directly and pass the unpacked xr.Dataset[apid] to each test, that can be helpful too.

IALiRT test fixtures are now stale (surfaced in #3262)

While finishing #3262 we hit a deeper issue with the CoDICE-IALiRT test (imap_processing/tests/ialirt/unit/test_process_codice.py):

  • It feeds on legacy imap_codice_l0_*-ialirt_*.pkts fixtures, but IALiRT no longer comes from that kind of L0 packet — per Joey (CoDICE), IALiRT is now its own thing, sourced from a LASP-developed API. So the test's input format no longer reflects how IALiRT data is actually produced; matching the science products' new 20260204 epoch would have required fabricating synthetic packets, which we declined to do.
  • As a stopgap, Restore strict CoDICE L2 spin_angle validation once 20260204 L0 packets are uploaded #3262 decouples the IALiRT test from the shared validation constants and pins it at the existing 20250814_v015 IALiRT data via dedicated IALIRT_VALIDATION_FILE_DATE/IALIRT_VALIDATION_FILE_VERSION constants. That keeps it passing but adds yet another date split — exactly the coupling smell this refactor should eliminate.

This refactor should reconcile the IALiRT test fixtures with the real (LASP-API) data source rather than legacy packet files. The IALiRT team (e.g. @laspsandoval) should weigh in on how that test data ought to be produced going forward.

Scope

Context / related

Metadata

Metadata

Assignees

Labels

Ins: CoDICERelated to the CoDICE instrument

Type

No type
No fields configured for issues without a type.

Projects

Status
Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions