Skip to content

Commit

Permalink
Merge branch 'dev' into fix_appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Jan 15, 2016
2 parents c5e8c07 + 670be17 commit 6513719
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 19 deletions.
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install:
- "set PATH=%QTDIR%\\bin;%PATH%"

- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "SET QT_QPA_PLATFORM_PLUGIN_PATH=C:\\Qt\\5.6\\5.6\\msvc_2015\\plugins\\platforms"
- "SET QT_PLUGIN_PATH=C:\\Qt\\5.6\\5.6\\msvc_2015\\plugins"
- choco install -y vcredist2015
- "%CMD_IN_ENV% conda config --set always_yes yes --set changeps1 no"
- "%CMD_IN_ENV% conda config --add channels inso/channel/sakia"
Expand Down Expand Up @@ -72,3 +72,5 @@ deploy:
on:
appveyor_repo_tag: true

on_finish:
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2 changes: 1 addition & 1 deletion ci/appveyor/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
call activate test-environment

echo "%PATH%"
echo "%QT_QPA_PLATFORM_PLUGIN_PATH%"
echo "%QT_PLUGIN_PATH%"
python -V
call pyuic5 --version

Expand Down
4 changes: 3 additions & 1 deletion ci/appveyor/tests.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
call activate test-environment

echo "%PATH%"
echo "%QT_QPA_PLATFORM_PLUGIN_PATH%"
echo "%QT_PLUGIN_PATH%"
python -V
call pyuic5 --version

pyrcc5 -version

lrelease -version

echo "%CWD%"

python setup.py test

if %errorlevel% neq 0 exit /b 1
6 changes: 3 additions & 3 deletions ci/travis/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ then
--enable QtCore \
--enable QtWidgets \
--enable QtGui \
--enable QtSvg \
--enable QtSvg\
--enable QtTest
elif [ $TRAVIS_OS_NAME == "linux" ]
then
python configure.py --qmake "/usr/lib/x86_64-linux-gnu/qt5/bin/qmake" --confirm-license \
--enable QtCore \
--enable QtWidgets \
--enable QtGui \
--enable QtSvg \
--enable QtSvg\
--enable QtTest
fi

make -j 2 && make install
pyenv rehash

fi
fi
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ucoinpy>=0.13
quamash
git+https://github.com/Insoleet/quamash.git@qeventloop
asynctest
networkx
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))

if "test" in sys.argv:
print(sys.path)
if "XDG_CONFIG_HOME" in os.environ:
os.environ["XDG_CONFIG_HOME"] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp'))
elif "HOME" in os.environ:
os.environ["HOME"] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp'))
elif "APPDATA" in os.environ:
os.environ["APPDATA"] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp'))
runner = unittest.TextTestRunner().run(unittest.defaultTestLoader.discover(start_dir='sakia.tests',
pattern='test_*'))

Expand Down
4 changes: 3 additions & 1 deletion src/sakia/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,5 +522,7 @@ async def get_last_version(self):
logging.debug("Current version : {0}".format(__version__))
self.available_version = version
self.version_requested.emit()
except aiohttp.errors.ClientError as e:
except (aiohttp.errors.ClientError, aiohttp.errors.TimeoutError) as e:
logging.debug("Could not connect to github : {0}".format(str(e)))
except Exception as e:
pass
1 change: 0 additions & 1 deletion src/sakia/gui/graphs/graph_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,5 @@ def changeEvent(self, event):
"""
if event.type() == QEvent.LanguageChange:
self.retranslateUi(self)
self._auto_refresh(None)
self.refresh()
return super().changeEvent(event)
4 changes: 2 additions & 2 deletions src/sakia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# To force cx_freeze import
import PyQt5.QtSvg

from quamash import QEventLoop
from quamash import QEventLoopSelector
from PyQt5.QtWidgets import QApplication
from sakia.gui.mainwindow import MainWindow
from sakia.core.app import Application
Expand Down Expand Up @@ -61,7 +61,7 @@ def async_exception_handler(loop, context):
# activate ctrl-c interrupt
signal.signal(signal.SIGINT, signal.SIG_DFL)
sakia = QApplication(sys.argv)
loop = QEventLoop(sakia)
loop = QEventLoopSelector(sakia)
loop.set_exception_handler(async_exception_handler)
asyncio.set_event_loop(loop)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def setUp(self):
def tearDown(self):
self.tearDownQuamash()

@unittest.skipIf(sys.platform== "darwin", "Test not working on OSX, but feature is OK")
def test_register_community_empty_blockchain(self):
mock = new_blockchain.get_mock(self.lp)
time.sleep(2)
Expand Down Expand Up @@ -96,7 +95,6 @@ async def exec_test():
self.lp.run_until_complete(process_community.async_exec())
self.assertEqual(process_community.result(), QDialog.Accepted)

@unittest.skipIf(sys.platform== "darwin", "Test not working on OSX, but feature is OK")
def test_connect_community_empty_blockchain(self):
mock = new_blockchain.get_mock(self.lp)
time.sleep(2)
Expand Down Expand Up @@ -143,7 +141,6 @@ async def exec_test():
asyncio.ensure_future(exec_test())
self.lp.run_until_complete(process_community.async_exec())

@unittest.skipIf(sys.platform== "darwin", "Test not working on OSX, but feature is OK")
def test_connect_community_wrong_pubkey(self):
mock = nice_blockchain.get_mock(self.lp)
time.sleep(2)
Expand Down Expand Up @@ -185,7 +182,6 @@ async def exec_test():
self.lp.run_until_complete(process_community.async_exec())
self.assertEqual(process_community.result(), QDialog.Rejected)

@unittest.skipIf(sys.platform== "darwin", "Test not working on OSX, but feature is OK")
def test_connect_community_wrong_uid(self):
mock = nice_blockchain.get_mock(self.lp)
time.sleep(2)
Expand Down Expand Up @@ -227,7 +223,6 @@ async def exec_test():
self.lp.run_until_complete(process_community.async_exec())
self.assertEqual(process_community.result(), QDialog.Rejected)

@unittest.skipIf(sys.platform== "darwin", "Test not working on OSX, but feature is OK")
def test_connect_community_success(self):
mock = nice_blockchain.get_mock(self.lp)
time.sleep(2)
Expand Down
4 changes: 2 additions & 2 deletions src/sakia/tests/mocks/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def bma_peering_generator(port):
"version": 1,
"currency": "test_currency",
"endpoints": [
"BASIC_MERKLED_API localhost 127.0.0.1 {port}".format(port=port)
"BASIC_MERKLED_API 127.0.0.1 {port}".format(port=port)
],
"status": "UP",
"block": "30152-00003E7F9234E7542FCF669B69B0F84FF79CCCD3",
"signature": "cXuqZuDfyHvxYAEUkPH1TQ1M+8YNDpj8kiHGYi3LIaMqEdVqwVc4yQYGivjxFMYyngRfxXkyvqBKZA6rKOulCA==",
"raw": "Version: 1\nType: Peer\nCurrency: meta_brouzouf\nPublicKey: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk\nBlock: 30152-00003E7F9234E7542FCF669B69B0F84FF79CCCD3\nEndpoints:\nBASIC_MERKLED_API localhost 127.0.0.1 {port}\n".format(port=port),
"raw": "Version: 1\nType: Peer\nCurrency: meta_brouzouf\nPublicKey: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk\nBlock: 30152-00003E7F9234E7542FCF669B69B0F84FF79CCCD3\nEndpoints:\nBASIC_MERKLED_API 127.0.0.1 {port}\n".format(port=port),
"pubkey": "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
}

Expand Down
2 changes: 1 addition & 1 deletion src/sakia/tests/quamash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class QuamashTest:
def setUpQuamash(self):
self.qapplication = get_application()
self.lp = quamash.QEventLoop(self.qapplication)
self.lp = quamash.QEventLoopSelector(self.qapplication)
asyncio.set_event_loop(self.lp)
self.lp.set_exception_handler(lambda l, c: unitttest_exception_handler(self, l, c))
self.exceptions = []
Expand Down
28 changes: 28 additions & 0 deletions src/sakia/tests/unit/core/test_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import aiohttp
import sys
import unittest
import asyncio
from asynctest.mock import Mock, CoroutineMock, patch
from PyQt5.QtCore import QLocale
from sakia.tests import QuamashTest
from sakia.core import Application


class TestApplication(unittest.TestCase, QuamashTest):
def setUp(self):
self.setUpQuamash()
QLocale.setDefault(QLocale("en_GB"))

def tearDown(self):
self.tearDownQuamash()

@patch('sakia.core.registry.IdentitiesRegistry')
@patch('aiohttp.get', CoroutineMock(side_effect=lambda *args, **kwargs: exec('raise aiohttp.errors.TimeoutError()')))
def test_get_last_version_timeout(self, identities_registry):
app = Application(self.qapplication, self.lp, identities_registry)

async def exec_test():
app.get_last_version()
asyncio.sleep(5)

self.lp.run_until_complete(exec_test())

0 comments on commit 6513719

Please sign in to comment.