id3c.tests.test_expected_frame_count#

Tests for id3c.plans.flyscan_3idc._expected_frame_count.

The helper provides the “expected” frame count stamped as provenance on /entry/flyscan_data (issue #12, phase A). It must:

  • prefer the authoritative AD HDF1 file count when a path is given;

  • fall back to the start document’s num_frames otherwise;

  • return None when neither source is available;

  • never raise.

Synthetic AD files are built via h5py; runs are duck-typed dicts. No IOC, no live detector, no catalog.

Attributes#

Functions#

test_ad_file_count_is_authoritative(tmp_path)

When the AD file is openable, its UID row count is returned.

test_falls_back_to_num_frames_when_no_ad_path()

With ad_file_path=None, the start-doc num_frames is used.

test_falls_back_to_num_frames_when_ad_file_missing(...)

A non-openable AD path falls through to num_frames.

test_falls_back_when_ad_file_lacks_uid_dataset(tmp_path)

An AD file without the UID dataset falls through to num_frames.

test_returns_none_when_no_source(tmp_path)

No AD file and no num_frames -> None (not an exception).

test_returns_none_when_num_frames_is_none()

An explicit num_frames=None is treated as absent.

test_never_raises_on_bad_run_object()

A run object with no usable metadata yields None, not an error.

test_ad_count_used_even_when_metadata_unusable(tmp_path)

AD file count is returned regardless of a broken run object.

test_returns_plain_int(tmp_path)

The result is a built-in int (HDF5/JSON attr friendly).

Module Contents#

id3c.tests.test_expected_frame_count.UID_DSET = '/entry/instrument/detector/NDAttributes/NDArrayUniqueId'[source]#
id3c.tests.test_expected_frame_count.test_ad_file_count_is_authoritative(tmp_path)[source]#

When the AD file is openable, its UID row count is returned.

id3c.tests.test_expected_frame_count.test_falls_back_to_num_frames_when_no_ad_path()[source]#

With ad_file_path=None, the start-doc num_frames is used.

id3c.tests.test_expected_frame_count.test_falls_back_to_num_frames_when_ad_file_missing(tmp_path)[source]#

A non-openable AD path falls through to num_frames.

id3c.tests.test_expected_frame_count.test_falls_back_when_ad_file_lacks_uid_dataset(tmp_path)[source]#

An AD file without the UID dataset falls through to num_frames.

id3c.tests.test_expected_frame_count.test_returns_none_when_no_source(tmp_path)[source]#

No AD file and no num_frames -> None (not an exception).

id3c.tests.test_expected_frame_count.test_returns_none_when_num_frames_is_none()[source]#

An explicit num_frames=None is treated as absent.

id3c.tests.test_expected_frame_count.test_never_raises_on_bad_run_object()[source]#

A run object with no usable metadata yields None, not an error.

id3c.tests.test_expected_frame_count.test_ad_count_used_even_when_metadata_unusable(tmp_path)[source]#

AD file count is returned regardless of a broken run object.

id3c.tests.test_expected_frame_count.test_returns_plain_int(tmp_path)[source]#

The result is a built-in int (HDF5/JSON attr friendly).