test_FTP_dialog.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # coding=utf-8
  2. """Dialog test.
  3. .. note:: This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. """
  8. __author__ = 'admin@siwei.com'
  9. __date__ = '2024-09-03'
  10. __copyright__ = 'Copyright 2024, siwei'
  11. import unittest
  12. from qgis.PyQt.QtGui import QDialogButtonBox, QDialog
  13. from FTP_dialog import FTPDialog
  14. from utilities import get_qgis_app
  15. QGIS_APP = get_qgis_app()
  16. class FTPDialogTest(unittest.TestCase):
  17. """Test dialog works."""
  18. def setUp(self):
  19. """Runs before each test."""
  20. self.dialog = FTPDialog(None)
  21. def tearDown(self):
  22. """Runs after each test."""
  23. self.dialog = None
  24. def test_dialog_ok(self):
  25. """Test we can click OK."""
  26. button = self.dialog.button_box.button(QDialogButtonBox.Ok)
  27. button.click()
  28. result = self.dialog.result()
  29. self.assertEqual(result, QDialog.Accepted)
  30. def test_dialog_cancel(self):
  31. """Test we can click cancel."""
  32. button = self.dialog.button_box.button(QDialogButtonBox.Cancel)
  33. button.click()
  34. result = self.dialog.result()
  35. self.assertEqual(result, QDialog.Rejected)
  36. if __name__ == "__main__":
  37. suite = unittest.makeSuite(FTPDialogTest)
  38. runner = unittest.TextTestRunner(verbosity=2)
  39. runner.run(suite)