Merge branch 'v0.6' of https://github.com/Bitmessage/PyBitmessage into py3porting
This commit is contained in:
commit
0dd9c85831
|
@ -6,12 +6,14 @@ addons:
|
|||
packages:
|
||||
- build-essential
|
||||
- libcap-dev
|
||||
- python-qt4
|
||||
- tor
|
||||
- xvfb
|
||||
install:
|
||||
- pip install -r requirements.txt
|
||||
- ln -s src pybitmessage # tests environment
|
||||
- python setup.py install
|
||||
script:
|
||||
- python checkdeps.py
|
||||
- src/bitmessagemain.py -t
|
||||
- xvfb-run src/bitmessagemain.py -t
|
||||
- python setup.py test
|
||||
|
|
|
@ -362,11 +362,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()
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
"""
|
||||
src/bitmessageqt/dialogs.py
|
||||
===========================
|
||||
Custom dialog classes
|
||||
"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
from PyQt4 import QtGui
|
||||
|
||||
import paths
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Sound Module"""
|
||||
|
||||
# sound type constants
|
||||
SOUND_NONE = 0
|
||||
|
@ -12,10 +13,12 @@ SOUND_CONNECTION_GREEN = 5
|
|||
# returns true if the given sound category is a connection sound
|
||||
# rather than a received message sound
|
||||
def is_connection_sound(category):
|
||||
"""Check if sound type is related to connectivity"""
|
||||
return category in (
|
||||
SOUND_CONNECTED,
|
||||
SOUND_DISCONNECTED,
|
||||
SOUND_CONNECTION_GREEN
|
||||
)
|
||||
|
||||
|
||||
extensions = ('wav', 'mp3', 'oga')
|
||||
|
|
|
@ -88,7 +88,7 @@ def createAddressIfNeeded(myapp):
|
|||
if not checkHasNormalAddress():
|
||||
queues.addressGeneratorQueue.put((
|
||||
'createRandomAddress', 4, 1,
|
||||
SUPPORT_MY_LABEL.toUtf8(),
|
||||
str(SUPPORT_MY_LABEL.toUtf8()),
|
||||
1, "", False,
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
defaults.networkDefaultPayloadLengthExtraBytes
|
||||
|
|
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)
|
||||
|
|
Reference in New Issue
Block a user