Started writing tests

This commit is contained in:
Dmitri Bogomolov 2018-11-20 18:46:07 +02:00
parent 0c4d1b4e32
commit efcbc651a3
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
4 changed files with 56 additions and 2 deletions

View File

@ -373,9 +373,9 @@ class Main:
time.time() - state.last_api_response >= 30):
self.stop()
elif not state.enableGUI:
state.enableGUI = True
from tests import core as test_core # pylint: disable=relative-import
test_core_result = test_core.run()
state.enableGUI = True
self.stop()
test_core.cleanup()
sys.exit(

View File

@ -0,0 +1,3 @@
from main import TestMain
__all__ = ["TestMain"]

View File

@ -0,0 +1,44 @@
"""
A tests for MainWindow
"""
import unittest
from PyQt4 import QtCore, QtGui, QtTest
import bitmessageqt
from tr import _translate
app = QtGui.QApplication([])
class TestMain(unittest.TestCase):
"""A test case for MainWindow"""
def setUp(self):
self.window = bitmessageqt.MainWindow()
def test_defaults(self):
tab_widget = self.window.tabWidget
self.assertEqual(tab_widget.count(), 6)
self.assertEqual(tab_widget.currentIndex(), 0)
self.assertEqual(
tab_widget.tabText(0), _translate("MainWindow", "Messages"))
self.assertEqual(
tab_widget.tabText(1), _translate("MainWindow", "Send"))
self.assertEqual(
tab_widget.tabText(2), _translate("MainWindow", "Subscriptions"))
self.assertEqual(
tab_widget.tabText(3), _translate("MainWindow", "Chans"))
self.assertEqual(
tab_widget.tabText(5),
_translate("MainWindow", "Network Status"))
menu_actions = self.window.menubar.actions()
self.assertEqual(len(menu_actions), 3)
self.assertEqual(
menu_actions[0].text(), _translate("MainWindow", "File"))
self.assertEqual(
menu_actions[1].text(), _translate("MainWindow", "Settings"))
self.assertEqual(
menu_actions[2].text(), _translate("MainWindow", "Help"))

View File

@ -112,7 +112,14 @@ class TestCore(unittest.TestCase):
def run():
"""Starts all tests defined in this module"""
loader = unittest.TestLoader()
loader = unittest.defaultTestLoader
loader.sortTestMethodsUsing = None
suite = loader.loadTestsFromTestCase(TestCore)
try:
import bitmessageqt.tests
except ImportError:
pass
else:
qt_tests = loader.loadTestsFromModule(bitmessageqt.tests)
suite.addTests(qt_tests)
return unittest.TextTestRunner(verbosity=2).run(suite)