Skip to content

Commit

Permalink
Update test_PrintDialog.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusHackspacher authored Jul 26, 2023
1 parent 4188378 commit db5543c
Showing 1 changed file with 15 additions and 36 deletions.
51 changes: 15 additions & 36 deletions tests/test_PrintDialog.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
import unittest
from printdialog import PrintDialog
from modules.gui.printdialog import DlgPrint


class TestPrintDialog(unittest.TestCase):
def test_handle_print(qtbot):
dialog = DlgPrint()
qtbot.addWidget(dialog)
editor = dialog.editor
editor.setText('This is a test')
dialog.handle_print()
assert dialog.buttonPrint.isEnabled()

def test_print_dialog(self):
# Create a new PrintDialog object
dialog = PrintDialog()

# Check that the dialog is created successfully
self.assertIsInstance(dialog, PrintDialog)

# Check that the dialog has the correct title
self.assertEqual(dialog.windowTitle(), "Print Dialog")

# Check that the dialog has the correct layout
self.assertEqual(dialog.layout().count(), 3)

# Check that the first row in the layout contains the correct widgets
self.assertEqual(dialog.layout().itemAt(0).widget(), dialog.label_archer)
self.assertEqual(dialog.layout().itemAt(1).widget(), dialog.combo_archer)
self.assertEqual(dialog.layout().itemAt(2).widget(), dialog.button_ok)

# Check that the second row in the layout contains the correct widgets
self.assertEqual(dialog.layout().itemAt(3).widget(), dialog.label_arrow)
self.assertEqual(dialog.layout().itemAt(4).widget(), dialog.combo_arrow)
self.assertEqual(dialog.layout().itemAt(5).widget(), dialog.button_cancel)

# Check that the dialog's `show()` method works correctly
dialog.show()
self.assertIsTrue(dialog.isVisible())

# Check that the dialog's `hide()` method works correctly
dialog.hide()
self.assertIsFalse(dialog.isVisible())

# Check that the dialog's `exec_()` method works correctly
dialog.exec_()
self.assertIsFalse(dialog.isVisible())

def test_handle_preview(qtbot):
dialog = DlgPrint()
qtbot.addWidget(dialog)
editor = dialog.editor
editor.setText('This is a test')
dialog.handle_preview()
assert dialog.buttonPreview.isEnabled()

if __name__ == "__main__":
unittest.main()

0 comments on commit db5543c

Please sign in to comment.