test_dataladcmd_ui.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from PySide6.QtWidgets import (
  2. QDialogButtonBox,
  3. QPushButton
  4. )
  5. from PySide6.QtCore import Qt
  6. from ..dataladcmd_ui import GooeyDataladCmdUI
  7. from datalad.tests.utils_pytest import (
  8. assert_equal,
  9. assert_false,
  10. assert_in,
  11. assert_is_not_none,
  12. assert_true,
  13. )
  14. def test_GooeyDataladCmdUI(gooey_app, *, qtbot):
  15. qtbot.addWidget(gooey_app.main_window)
  16. cmdui = GooeyDataladCmdUI(gooey_app, gooey_app.get_widget('cmdTab'))
  17. cmdui.configure({}, 'wtf', {})
  18. # command tab is set up:
  19. assert_true(cmdui.pwidget.isEnabled())
  20. assert_equal(
  21. gooey_app.get_widget('contextTabs').currentWidget().objectName(),
  22. "cmdTab")
  23. assert_equal(cmdui._cmd_title.text().lower(), "wtf")
  24. # click OK and see the correct signal:
  25. buttonbox = cmdui.pwidget.findChild(QDialogButtonBox, 'cmdTabButtonBox')
  26. ok_button = buttonbox.button(QDialogButtonBox.StandardButton.Ok)
  27. assert_is_not_none(ok_button)
  28. with qtbot.waitSignal(cmdui.configured_dataladcmd) as blocker:
  29. qtbot.mouseClick(ok_button, Qt.LeftButton)
  30. assert_equal(blocker.args[0], 'wtf')
  31. # no parameters given, means none passed via signal:
  32. assert_equal({}, blocker.args[1])
  33. # reset_form
  34. cmdui.reset_form()
  35. assert_equal(cmdui._cmd_title.text().lower(), "")
  36. assert_false(cmdui.pwidget.isEnabled())