MCPcopy Create free account
hub / github.com/github/spec-kit / test_init_and_load_share_validation

Method test_init_and_load_share_validation

tests/test_workflows.py:4182–4213  ·  view source on GitHub ↗

``__init__`` *and* ``load`` reject the same malformed IDs. The two entry points must stay in sync — drift would let an ID slip in via one path that the other would reject, producing confusing crashes mid-workflow. The previous version of this test only exercised ``__

(self, project_dir, bad_run_id)

Source from the content-addressed store, hash-verified

4180 ],
4181 )
4182 def test_init_and_load_share_validation(self, project_dir, bad_run_id):
4183 """``__init__`` *and* ``load`` reject the same malformed IDs.
4184
4185 The two entry points must stay in sync — drift would let an ID
4186 slip in via one path that the other would reject, producing
4187 confusing crashes mid-workflow. The previous version of this
4188 test only exercised ``__init__`` and ``_validate_run_id`` (the
4189 shared helper), so a regression in ``load`` — e.g. someone
4190 deleting the ``cls._validate_run_id(run_id)`` call there — could
4191 slip through despite ``__init__`` and the helper staying
4192 aligned. We now hit ``load`` directly with the same vector so
4193 any drift between the two call sites is caught by this test.
4194 """
4195 from specify_cli.workflows.engine import RunState
4196
4197 # ``__init__`` rejects up front.
4198 with pytest.raises(ValueError, match="Invalid run_id"):
4199 RunState(run_id=bad_run_id)
4200
4201 # The shared helper rejects the value too (sanity check that the
4202 # ``__init__`` rejection came from the validator, not some
4203 # unrelated constructor failure).
4204 with pytest.raises(ValueError, match="Invalid run_id"):
4205 RunState._validate_run_id(bad_run_id)
4206
4207 # And ``load`` rejects it *before* touching the filesystem. This
4208 # is the assertion the previous version was missing: without it,
4209 # a regression in ``load`` (e.g. forgetting to call the
4210 # validator before building the path) would not be caught even
4211 # though ``__init__`` and the helper still agreed.
4212 with pytest.raises(ValueError, match="Invalid run_id"):
4213 RunState.load(bad_run_id, project_dir)
4214
4215 def test_append_log(self, project_dir):
4216 from specify_cli.workflows.engine import RunState

Callers

nothing calls this directly

Calls 3

RunStateClass · 0.90
_validate_run_idMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected