Refactor command handler to add unit tests
Issues
- Handler class has no unit tests
- Integration tests do test some of the functionality (e.g.
integration-tests/test_filewriter_commands.py
), but these tests are flaky. - The design of the class has a number of problems (we do not necessarily address these issues in this PR):
- Overly complex methods
- Lack of dependency injection
- The public interface has a bunch of simple methods, but then there is an opaque method
loopFunction
where a lot of complexity is hidden. This makes the class difficult to test.
Description of work
- We refactor the chain of checks performed on start/stop commands. Instead of a single
void
function with many side effects, we know have a couple extra functions still with some side effects, but at least they return a response object that can be unit tested. - We add unit tests on the checks performed for incoming start/stop commands.
Checklist
-
Changes have been documented in changes.md
-
Documentation has been updated in documentation
directory
Edited by Daniel Cacabelos