sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Fix state-dependent callbacks #331

Closed taldcroft closed 1 month ago

taldcroft commented 1 month ago

Description

Some states require a callback function to determine the state transition value. That callback can depend on other state values. The existing code did not check that the state value was defined, in which case it would be None. In the case of #325 this would cause an exception. For the other state callbacks that are changed in this PR the existing code worked but somewhat accidentally.

I did an audit of all the callbacks. Callbacks with code like if state["eclipse_enable_spm"] were left unchanged since checking for None and returning would have the same effect.

Fixes #325

Interface impacts

None

Testing

Unit tests

kadi/commands/tests/test_commands.py ............................................................................... [ 43%] kadi/commands/tests/test_states.py .......................x......................... [ 71%] kadi/commands/tests/test_validate.py .................... [ 82%] kadi/tests/test_events.py .......... [ 87%] kadi/tests/test_occweb.py ...................... [100%]

Independent check of unit tests by Jean
- [x] Linux

ska3-jeanconn-fido> pytest ================================================= test session starts ================================================== platform linux -- Python 3.11.8, pytest-7.4.4, pluggy-1.4.0 rootdir: /proj/sot/ska/jeanproj/git configfile: pytest.ini plugins: anyio-4.3.0, timeout-2.2.0 collected 180 items

kadi/commands/tests/test_commands.py ........................................................................... [ 41%] .... [ 43%] kadi/commands/tests/test_states.py .......................x......................... [ 71%] kadi/commands/tests/test_validate.py .................... [ 82%] kadi/tests/test_events.py .......... [ 87%] kadi/tests/test_occweb.py ...................... [100%]

=================================================== warnings summary =================================================== kadi/kadi/commands/tests/test_commands.py::test_get_starcats_each_year[year0] /proj/sot/ska3/flight/lib/python3.11/site-packages/setuptools_scm/git.py:308: UserWarning: git archive did not support describe output warnings.warn("git archive did not support describe output")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ================================ 179 passed, 1 xfailed, 1 warning in 181.96s (0:03:01) ================================= ska3-jeanconn-fido> git rev-parse HEAD dd36d606367998375d5f97eb0efb1b4141bbf31e



### Functional tests
<!-- Describe and document results of any functional tests, otherwise leave the text below -->
No functional testing.