Skip to content

Add CLI testing and assorted fixes to make this possible

Peter Hutterer requested to merge whot/mr-label-maker:wip/tests into main

This MR adds a set of pytest-compatible tests and the CI to actually run those tests (together with the usual CI jobs). Notably, there's a bit of reshuffling to make the tests easier and clean up the code in general - together with a few bugfixes, primarily of argument types.

The tests themselves make use of unittest.mock.patch and MagicMock() so for now this just tests the cli, not the actual backend.

For those unfamiliar with patch and MagicMock, the code works like this: Usually mr_label_maker.main() creates a mesa.Mesa() object and then calls the various setters on it before calling proj.process_issues() and/or proj.process_mrs(). By using patch and MagicMock we fake a mesa.Mesa() object and then check that main() calls us with the expected arguments. This means we can hack on the CLI without having to care how/whether the actual backend works - as long as all the functions are called like before it'll work the same way.

Merge request reports