New package: bitmessageqt.tests
any test cases from it will be added to tests.core test suite if possible, e.g. PyQt is functional. TestSupport - minimal test case for support module to reproduce #1633.
This commit is contained in:
parent
ea109bc21e
commit
d6953eb450
|
@ -363,11 +363,12 @@ class Main(object):
|
|||
while state.shutdown == 0:
|
||||
time.sleep(1)
|
||||
if (
|
||||
state.testmode and time.time() -
|
||||
state.last_api_response >= 30
|
||||
state.testmode
|
||||
and time.time() - state.last_api_response >= 30
|
||||
):
|
||||
self.stop()
|
||||
elif not state.enableGUI:
|
||||
state.enableGUI = True
|
||||
# pylint: disable=relative-import
|
||||
from tests import core as test_core
|
||||
test_core_result = test_core.run()
|
||||
|
|
6
src/bitmessageqt/tests/__init__.py
Normal file
6
src/bitmessageqt/tests/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
"""bitmessageqt tests"""
|
||||
|
||||
from main import TestMain
|
||||
from support import TestSupport
|
||||
|
||||
__all__ = ["TestMain", "TestSupport"]
|
30
src/bitmessageqt/tests/main.py
Normal file
30
src/bitmessageqt/tests/main.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""Common definitions for bitmessageqt tests"""
|
||||
|
||||
import unittest
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
import bitmessageqt
|
||||
from tr import _translate
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
"""Base class for bitmessageqt test case"""
|
||||
|
||||
def setUp(self):
|
||||
self.app = QtGui.QApplication([])
|
||||
self.window = bitmessageqt.MyForm()
|
||||
|
||||
def tearDown(self):
|
||||
self.app.deleteLater()
|
||||
|
||||
|
||||
class TestMain(unittest.TestCase):
|
||||
"""Test case for main window - basic features"""
|
||||
|
||||
def test_translate(self):
|
||||
"""Check the results of _translate() with various args"""
|
||||
self.assertIsInstance(
|
||||
_translate("MainWindow", "Test"),
|
||||
QtCore.QString
|
||||
)
|
33
src/bitmessageqt/tests/support.py
Normal file
33
src/bitmessageqt/tests/support.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# from PyQt4 import QtTest
|
||||
|
||||
import sys
|
||||
|
||||
from shared import isAddressInMyAddressBook
|
||||
|
||||
from main import TestBase
|
||||
|
||||
|
||||
class TestSupport(TestBase):
|
||||
"""A test case for support module"""
|
||||
SUPPORT_ADDRESS = 'BM-2cUdgkDDAahwPAU6oD2A7DnjqZz3hgY832'
|
||||
SUPPORT_SUBJECT = 'Support request'
|
||||
|
||||
def test(self):
|
||||
"""trigger menu action "Contact Support" and check the result"""
|
||||
ui = self.window.ui
|
||||
self.assertEqual(ui.lineEditTo.text(), '')
|
||||
self.assertEqual(ui.lineEditSubject.text(), '')
|
||||
|
||||
ui.actionSupport.trigger()
|
||||
|
||||
self.assertTrue(
|
||||
isAddressInMyAddressBook(self.SUPPORT_ADDRESS))
|
||||
|
||||
self.assertEqual(
|
||||
ui.tabWidget.currentIndex(), ui.tabWidget.indexOf(ui.send))
|
||||
self.assertEqual(
|
||||
ui.lineEditTo.text(), self.SUPPORT_ADDRESS)
|
||||
self.assertEqual(
|
||||
ui.lineEditSubject.text(), self.SUPPORT_SUBJECT)
|
||||
self.assertIn(
|
||||
sys.version, ui.textEditMessage.toPlainText())
|
|
@ -30,7 +30,6 @@ try:
|
|||
except ImportError:
|
||||
stem_version = None
|
||||
|
||||
|
||||
knownnodes_file = os.path.join(state.appdata, 'knownnodes.dat')
|
||||
|
||||
|
||||
|
@ -245,7 +244,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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user