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
[x] Mac (new tests)
(ska3) ➜ kadi git:(fix-state-callbacks) git rev-parse HEAD
dd36d606367998375d5f97eb0efb1b4141bbf31e
(ska3) ➜ kadi git:(fix-state-callbacks) pytest
==================================================== test session starts =====================================================
platform darwin -- Python 3.11.8, pytest-7.4.4, pluggy-1.4.0
rootdir: /Users/aldcroft/git
configfile: pytest.ini
plugins: timeout-2.2.0, anyio-4.3.0
collecting ... Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
collected 180 items
=================================================== 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.
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 forNone
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%]
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