|
|
@@ -3,15 +3,19 @@
|
|
|
import logging
|
|
|
import os
|
|
|
import platform
|
|
|
+from qgis.core import QgsProject
|
|
|
import subprocess
|
|
|
+import unittest
|
|
|
|
|
|
from PyQt5 import QtWidgets
|
|
|
from PyQt5 import uic
|
|
|
-from PyQt5.QtCore import Qt
|
|
|
+from PyQt5.QtCore import Qt, QFileInfo
|
|
|
from PyQt5.QtGui import QIcon, QPixmap
|
|
|
+from PyQt5.QtWidgets import QTextBrowser
|
|
|
|
|
|
-from core.constants import MAIN, LOGDIR, RSCDIR, CONTACT
|
|
|
+from core.constants import MAIN, LOGDIR, RSCDIR, CONTACT, TESTDIR, DEBUG
|
|
|
from path import Path
|
|
|
+from test._stream import TestStream
|
|
|
|
|
|
|
|
|
logger = logging.getLogger("mncheck")
|
|
|
@@ -40,6 +44,9 @@ class DlgContact(QtWidgets.QDialog):
|
|
|
self.ui.lbl_mail.setOpenExternalLinks(True)
|
|
|
|
|
|
self.ui.btn_open_log_dir.clicked.connect(self.open_log_dir)
|
|
|
+
|
|
|
+ self.ui.btn_test.setVisible(DEBUG)
|
|
|
+ self.ui.btn_test.clicked.connect(self.run_tests)
|
|
|
|
|
|
def open_log_dir(self):
|
|
|
path = Path(LOGDIR).abspath()
|
|
|
@@ -48,3 +55,23 @@ class DlgContact(QtWidgets.QDialog):
|
|
|
else:
|
|
|
subprocess.Popen(["open", path])
|
|
|
|
|
|
+ def run_tests(self):
|
|
|
+ _initial_project = QgsProject.instance().absoluteFilePath()
|
|
|
+ if _initial_project:
|
|
|
+ QgsProject.instance().write(QFileInfo(_initial_project))
|
|
|
+
|
|
|
+ loader = unittest.TestLoader()
|
|
|
+ tests = loader.discover(Path(TESTDIR).abspath())
|
|
|
+
|
|
|
+ with open(LOGDIR / "checkup.txt", "w+") as f:
|
|
|
+ runner = unittest.TextTestRunner(stream=f)
|
|
|
+ runner.run(tests)
|
|
|
+
|
|
|
+ if _initial_project:
|
|
|
+ QgsProject.instance().clear()
|
|
|
+ QgsProject.read(QFileInfo(_initial_project))
|
|
|
+
|
|
|
+ with open(LOGDIR / "checkup.txt", "r") as f:
|
|
|
+ dlg = QTextBrowser()
|
|
|
+ dlg.setText(f.read())
|
|
|
+ dlg.show()
|