(manual_command_sets_app, capsys)
| 238 | |
| 239 | |
| 240 | def test_load_commands(manual_command_sets_app, capsys) -> None: |
| 241 | # now install a command set and verify the commands are now present |
| 242 | cmd_set = CommandSetA() |
| 243 | |
| 244 | assert manual_command_sets_app.find_commandset_for_command("elderberry") is None |
| 245 | assert not manual_command_sets_app.find_commandsets(CommandSetA) |
| 246 | |
| 247 | manual_command_sets_app.register_command_set(cmd_set) |
| 248 | |
| 249 | assert manual_command_sets_app.find_commandsets(CommandSetA)[0] is cmd_set |
| 250 | assert manual_command_sets_app.find_commandset_for_command("elderberry") is cmd_set |
| 251 | |
| 252 | out = manual_command_sets_app.app_cmd("apple") |
| 253 | assert "Apple!" in out.stdout |
| 254 | |
| 255 | # Make sure registration callbacks ran |
| 256 | out, _err = capsys.readouterr() |
| 257 | assert "in on_register now" in out |
| 258 | assert "in on_registered now" in out |
| 259 | |
| 260 | cmds_cats, _help_topics = manual_command_sets_app._build_command_info() |
| 261 | |
| 262 | assert "Alone" in cmds_cats |
| 263 | assert "elderberry" in cmds_cats["Alone"] |
| 264 | assert "main" in cmds_cats["Alone"] |
| 265 | |
| 266 | # Test subcommand was loaded |
| 267 | result = manual_command_sets_app.app_cmd("main sub") |
| 268 | assert "Subcommand Ran" in result.stdout |
| 269 | |
| 270 | assert "Fruits" in cmds_cats |
| 271 | assert "cranberry" in cmds_cats["Fruits"] |
| 272 | |
| 273 | # uninstall the command set and verify it is now also no longer accessible |
| 274 | manual_command_sets_app.unregister_command_set(cmd_set) |
| 275 | |
| 276 | cmds_cats, _help_topics = manual_command_sets_app._build_command_info() |
| 277 | |
| 278 | assert "Alone" not in cmds_cats |
| 279 | assert "Fruits" not in cmds_cats |
| 280 | |
| 281 | # Make sure unregistration callbacks ran |
| 282 | out, _err = capsys.readouterr() |
| 283 | assert "in on_unregister now" in out |
| 284 | assert "in on_unregistered now" in out |
| 285 | |
| 286 | # uninstall a second time and verify no errors happen |
| 287 | manual_command_sets_app.unregister_command_set(cmd_set) |
| 288 | |
| 289 | # reinstall the command set and verify it is accessible |
| 290 | manual_command_sets_app.register_command_set(cmd_set) |
| 291 | |
| 292 | cmds_cats, _help_topics = manual_command_sets_app._build_command_info() |
| 293 | |
| 294 | assert "Alone" in cmds_cats |
| 295 | assert "elderberry" in cmds_cats["Alone"] |
| 296 | assert "main" in cmds_cats["Alone"] |
| 297 |
nothing calls this directly
no test coverage detected
searching dependent graphs…