Skip to content

Commit

Permalink
Started writing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
g1itch committed Oct 17, 2019
1 parent edab264 commit b75d9ec
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bitmessagemain.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def start(self):
state.testmode and 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(self)
state.enableGUI = True
Expand Down
3 changes: 3 additions & 0 deletions src/bitmessageqt/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from main import TestMain

__all__ = ["TestMain"]
44 changes: 44 additions & 0 deletions src/bitmessageqt/tests/main.py
Original file line number Diff line number Diff line change
@@ -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"))
9 changes: 8 additions & 1 deletion src/tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@ def run(prog):
"""Starts all tests defined in this module"""
global program # pylint: disable=global-statement
program = prog
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)

0 comments on commit b75d9ec

Please sign in to comment.