diff --git a/.travis.yml b/.travis.yml index bc8add0e6f902887be11bcfc85b46d2a34684b4c..56a2d9115f1ad34b29db33f9aa1c0e609e16e7dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: - os: linux env: -- PYENV_PYTHON_VERSION=3.5.0 +- PYENV_PYTHON_VERSION=3.5.2 before_install: - ci/travis/before_install.sh diff --git a/ci/travis/after_success.sh b/ci/travis/after_success.sh index cb2acfb751351082ac3f7f3b078f53469136bf55..cb564e2d10f9e921aa935591fb7881735393d673 100755 --- a/ci/travis/after_success.sh +++ b/ci/travis/after_success.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash eval "$(pyenv init -)" -eval "$(pyenv virtualenv-init -)" cd $HOME/build/duniter/sakia -pyenv activate sakia-env +pyenv shell $PYENV_PYTHON_VERSION coverage -rm coveralls \ No newline at end of file diff --git a/ci/travis/before_install.sh b/ci/travis/before_install.sh index e115b6e5fca814a48ed1c2a66b54c2af0416272a..4a7ac8055c086af2940c1c302a9f6a6b98b87111 100755 --- a/ci/travis/before_install.sh +++ b/ci/travis/before_install.sh @@ -18,6 +18,7 @@ then brew install qt55 brew link --force qt55 brew install pyenv-virtualenv + pyenv update elif [ $TRAVIS_OS_NAME == "linux" ] then sudo apt-get update @@ -32,76 +33,74 @@ then wget http://archive.ubuntu.com/ubuntu/pool/universe/libs/libsodium/libsodium13_1.0.1-1_amd64.deb sudo dpkg -i libsodium13_1.0.1-1_amd64.deb - curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash - sudo lconfig + rm -r ~/.pyenv + git clone https://github.com/yyuu/pyenv.git ~/.pyenv + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile + echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile + ldconfig -p fi eval "$(pyenv init -)" -eval "$(pyenv virtualenv-init -)" -pyenv activate sakia-env -if [ $? -ne 0 ] +pyenv install --list +if [ $TRAVIS_OS_NAME == "osx" ] then - echo "Sakia env cache cleared, rebuilding it..." - if [ $TRAVIS_OS_NAME == "osx" ] - then - env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install $PYENV_PYTHON_VERSION - elif [ $TRAVIS_OS_NAME == "linux" ] - then - PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYENV_PYTHON_VERSION - fi - - pyenv shell $PYENV_PYTHON_VERSION - pyenv virtualenv sakia-env - - cd $HOME - - wget http://ufpr.dl.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz - file sip-4.17.tar.gz - gzip -t sip-4.17.tar.gz - tar xzf sip-4.17.tar.gz - cd sip-4.17/ - pyenv activate sakia-env - python configure.py - make && make install - pyenv rehash + env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install $PYENV_PYTHON_VERSION +elif [ $TRAVIS_OS_NAME == "linux" ] +then + PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYENV_PYTHON_VERSION +fi - cd $HOME +pyenv shell $PYENV_PYTHON_VERSION - wget http://ufpr.dl.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt-gpl-5.5.1.tar.gz - file PyQt-gpl-5.5.1.tar.gz - gzip -t PyQt-gpl-5.5.1.tar.gz - tar xzf PyQt-gpl-5.5.1.tar.gz - cd PyQt-gpl-5.5.1/ - pyenv activate sakia-env - if [ $TRAVIS_OS_NAME == "osx" ] - then - python configure.py --confirm-license \ - --enable QtCore \ - --enable QtWidgets \ - --enable QtGui \ - --enable QtSvg \ - --enable QtWebChannel \ - --enable QtWebEngineWidgets \ - --enable QtNetwork \ - --enable QtPrintSupport \ - --enable QtTest - elif [ $TRAVIS_OS_NAME == "linux" ] - then - python configure.py --qmake "/tmp/qt/5.5/5.5/gcc_64/bin/qmake" --confirm-license \ - --enable QtCore \ - --enable QtWidgets \ - --enable QtGui \ - --enable QtSvg \ - --enable QtWebChannel \ - --enable QtWebEngineWidgets \ - --enable QtNetwork \ - --enable QtPrintSupport \ - --enable QtTest - fi +cd $HOME - make -j 2 && make install - pyenv rehash +wget http://ufpr.dl.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz +file sip-4.17.tar.gz +gzip -t sip-4.17.tar.gz +tar xzf sip-4.17.tar.gz +cd sip-4.17/ +python configure.py +make && make install +pyenv rehash +cd $HOME +pyenv shell $PYENV_PYTHON_VERSION +wget http://ufpr.dl.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt-gpl-5.5.1.tar.gz +file PyQt-gpl-5.5.1.tar.gz +gzip -t PyQt-gpl-5.5.1.tar.gz +tar xzf PyQt-gpl-5.5.1.tar.gz +cd PyQt-gpl-5.5.1/ +if [ $TRAVIS_OS_NAME == "osx" ] +then + python configure.py --confirm-license \ + --enable QtCore \ + --enable QtWidgets \ + --enable QtGui \ + --enable QtSvg \ + --enable QtWebChannel \ + --enable QtWebEngineWidgets \ + --enable QtNetwork \ + --enable QtPrintSupport \ + --enable QtTest \ + --pyuic5-interpreter /Users/travis/.pyenv/versions/$PYENV_PYTHON_VERSION/bin/python3.5 \ + --sip /Users/travis/.pyenv/versions/$PYENV_PYTHON_VERSION/Python.framework/Versions/3.5/bin/sip +elif [ $TRAVIS_OS_NAME == "linux" ] +then + python configure.py --qmake "/tmp/qt/5.5/5.5/gcc_64/bin/qmake" --confirm-license \ + --enable QtCore \ + --enable QtWidgets \ + --enable QtGui \ + --enable QtSvg \ + --enable QtWebChannel \ + --enable QtWebEngineWidgets \ + --enable QtNetwork \ + --enable QtPrintSupport \ + --enable QtTest \ + --pyuic5-interpreter /home/travis/.pyenv/versions/$PYENV_PYTHON_VERSION/bin/python3.5 \ + --sip /home/travis/.pyenv/versions/3.5.2/bin/sip fi + +make -j 2 && make install +pyenv rehash diff --git a/ci/travis/build.sh b/ci/travis/build.sh index 0235b7f481065b11292caeb32fa6eddb4dd0ca99..4210041ea131a640c8df2ff3aee3707ad648d161 100755 --- a/ci/travis/build.sh +++ b/ci/travis/build.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash eval "$(pyenv init -)" -eval "$(pyenv virtualenv-init -)" cd $HOME/build/duniter/sakia - -pyenv activate sakia-env +pyenv shell $PYENV_PYTHON_VERSION +pip install --upgrade pip +pyenv rehash pip install coveralls pip install pyinstaller pip install -r requirements.txt @@ -17,6 +17,10 @@ then export PATH=/tmp/qt/5.5/5.5/gcc_64/bin:$PATH fi +if [ $TRAVIS_OS_NAME == "osx" ] +then + export PATH=/Users/travis/.pyenv/versions/$PYENV_PYTHON_VERSION/Python.framework/Versions/3.5/bin:$PATH +fi python gen_resources.py python gen_translations.py --lrelease diff --git a/ci/travis/test.sh b/ci/travis/test.sh index 23b92d82e8824fa4d6630cb1c7026640c0c032fd..25e05bd48cd516aa5028015cb12d1db915e956b9 100755 --- a/ci/travis/test.sh +++ b/ci/travis/test.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash eval "$(pyenv init -)" -eval "$(pyenv virtualenv-init -)" if [ $TRAVIS_OS_NAME == "linux" ] then @@ -12,6 +11,12 @@ then fi cd $HOME/build/duniter/sakia -pyenv activate sakia-env -coverage run --source=sakia.core,sakia.gui,sakia.models setup.py test +pyenv shell $PYENV_PYTHON_VERSION +if [ $TRAVIS_OS_NAME == "linux" ] +then + coverage run --source=sakia.core,sakia.gui,sakia.models setup.py test +else + python setup.py test +fi + diff --git a/requirements.txt b/requirements.txt index 847ac1a6b4e9387237eb3f6723554f601ea44d1c..145df061d3a4c6fa1c9cb843d1b39244403a12bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ duniterpy>=0.20.dev0 -git+https://github.com/harvimt/quamash.git@gh45 +git+https://github.com/Insoleet/quamash.git@master asynctest networkx \ No newline at end of file diff --git a/src/sakia/tests/functional/certification/test_certification.py b/src/sakia/tests/functional/certification/test_certification.py index 35b214c142704217197e70b86be4b39ed20ff37f..b836a9b8750e1ce20550b37eca6701f7f4821736 100644 --- a/src/sakia/tests/functional/certification/test_certification.py +++ b/src/sakia/tests/functional/certification/test_certification.py @@ -66,6 +66,7 @@ class TestCertificationDialog(unittest.TestCase, QuamashTest): srv, port, url = await self.mock_new_community.create_server() self.addCleanup(srv.close) await certification_dialog.async_exec() + await self.mock_new_community.close() def close_dialog(): if certification_dialog.widget.isVisible(): diff --git a/src/sakia/tests/functional/identities_tab/test_identities_table.py b/src/sakia/tests/functional/identities_tab/test_identities_table.py index f7855a2ad16c9153b208f1bf7955589765f479e2..c88876b6c16844d9565682bdbbd42231694cdb24 100644 --- a/src/sakia/tests/functional/identities_tab/test_identities_table.py +++ b/src/sakia/tests/functional/identities_tab/test_identities_table.py @@ -78,7 +78,7 @@ class TestIdentitiesTable(unittest.TestCase, QuamashTest): await asyncio.sleep(2) self.assertEqual(identities_tab.ui.table_identities.model().rowCount(), 1) - await asyncio.sleep(2) + await self.mock_nice_blockchain.close() self.lp.call_soon(close_dialog) asyncio.ensure_future(exec_test()) diff --git a/src/sakia/tests/functional/main_window/test_main_window_dialogs.py b/src/sakia/tests/functional/main_window/test_main_window_dialogs.py index 422f9ded275efc8110b237bd657ecc77170ede68..ed9157a9816b196643e7ed133ec8d2a053c53779 100644 --- a/src/sakia/tests/functional/main_window/test_main_window_dialogs.py +++ b/src/sakia/tests/functional/main_window/test_main_window_dialogs.py @@ -1,4 +1,5 @@ import unittest +import asyncio from PyQt5.QtWidgets import QDialog, QFileDialog from PyQt5.QtCore import QLocale, QTimer from sakia.gui.mainwindow import MainWindow @@ -31,21 +32,19 @@ class MainWindowDialogsTest(unittest.TestCase, QuamashTest): break def test_action_add_account(self): - #asynchronous test, cause dialog is waiting user response - QTimer.singleShot(1, self._async_test_action_add_account) - #select menu - self.main_window.ui.action_add_account.trigger() - - def _async_test_action_add_account(self): - widgets = self.qapplication.topLevelWidgets() - for widget in widgets: - if isinstance(widget, QDialog): - if widget.isVisible(): - try: - self.assertEqual('AccountConfigurationDialog', widget.objectName()) - break - finally: - widget.close() + async def exec_test(): + self.main_window.ui.action_add_account.trigger() + await asyncio.sleep(1) + widgets = self.qapplication.topLevelWidgets() + for widget in widgets: + if isinstance(widget, QDialog): + if widget.isVisible(): + try: + self.assertEqual('AccountConfigurationDialog', widget.objectName()) + break + finally: + widget.close() + self.lp.run_until_complete(exec_test()) # fixme: require a app.current_account fixture # def test_action_configure_account(self): diff --git a/src/sakia/tests/functional/process_cfg_community/test_add_community.py b/src/sakia/tests/functional/process_cfg_community/test_add_community.py index 256dcba78acfdc9a33e2e0f3b3ba99afabeaead7..28b6da2b9da1561175478e6872ce42a3ce1a331d 100644 --- a/src/sakia/tests/functional/process_cfg_community/test_add_community.py +++ b/src/sakia/tests/functional/process_cfg_community/test_add_community.py @@ -67,6 +67,7 @@ class ProcessAddCommunity(unittest.TestCase, QuamashTest): self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_add_nodes, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) + await mock.close() QTest.mouseClick(process_community.button_next, Qt.LeftButton) self.lp.call_later(15, close_dialog) @@ -107,6 +108,7 @@ class ProcessAddCommunity(unittest.TestCase, QuamashTest): process_community.page_node, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) self.assertEqual(process_community.label_error.text(), "Could not find your identity on the network.") + await mock.close() process_community.close() self.lp.call_later(15, close_dialog) @@ -147,6 +149,7 @@ class ProcessAddCommunity(unittest.TestCase, QuamashTest): '/wot/certifiers-of/wrong_pubkey') self.assertEqual(process_community.label_error.text(), """Your pubkey or UID is different on the network. Yours : wrong_pubkey, the network : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ""") + await mock.close() process_community.close() self.lp.call_later(15, close_dialog) @@ -185,6 +188,7 @@ Yours : wrong_pubkey, the network : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.assertEqual(mock.get_request(0).url, '/network/peering') self.assertEqual(process_community.label_error.text(), """Your pubkey or UID is different on the network. Yours : wrong_uid, the network : john""") + await mock.close() process_community.close() self.lp.call_later(15, close_dialog) @@ -205,8 +209,6 @@ Yours : wrong_uid, the network : john""") async def exec_test(): srv, port, url = await mock.create_server() - self.addCleanup(srv.close) - await asyncio.sleep(1) QTest.mouseClick(process_community.lineedit_server, Qt.LeftButton) QTest.keyClicks(process_community.lineedit_server, "127.0.0.1") QTest.mouseDClick(process_community.spinbox_port, Qt.LeftButton) @@ -226,6 +228,7 @@ Yours : wrong_uid, the network : john""") self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_add_nodes, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) + await mock.close() QTest.mouseClick(process_community.button_next, Qt.LeftButton) self.lp.call_later(15, close_dialog) diff --git a/src/sakia/tests/functional/transfer/test_transfer.py b/src/sakia/tests/functional/transfer/test_transfer.py index 6f83afb8f5f52ba2a08d7a100ef87f140f2b324c..ad8df3cfeac386ad932bf8b61122e3e7bcdd423a 100644 --- a/src/sakia/tests/functional/transfer/test_transfer.py +++ b/src/sakia/tests/functional/transfer/test_transfer.py @@ -65,6 +65,7 @@ class TestTransferDialog(unittest.TestCase, QuamashTest): self.addCleanup(srv.close) await asyncio.sleep(1) result = await transfer_dialog.async_exec() + await self.mock_nice_blockchain.close() self.assertEqual(result, QDialog.Accepted) def close_dialog(): diff --git a/src/sakia/tests/functional/wot_tab/test_wot_tab.py b/src/sakia/tests/functional/wot_tab/test_wot_tab.py index 1beeddb02b372fa391b6dafd22f066b028f4d34e..3eb15fc3cd96070da5da77719c0e6dc079f8d8b5 100644 --- a/src/sakia/tests/functional/wot_tab/test_wot_tab.py +++ b/src/sakia/tests/functional/wot_tab/test_wot_tab.py @@ -63,6 +63,7 @@ class TestWotTab(unittest.TestCase, QuamashTest): srv, port, url = await self.mock_nice_blockchain.create_server() self.addCleanup(srv.close) await open_widget() + await self.mock_nice_blockchain.close() def close_dialog(): if wot_tab.widget.isVisible(): diff --git a/src/sakia/tests/mocks/server.py b/src/sakia/tests/mocks/server.py index 38af9e963f52a1b65f6a3fb6cd94d5de652bf8a9..14bb1317acefbac9805c15e19ba08ba52b15e0c5 100644 --- a/src/sakia/tests/mocks/server.py +++ b/src/sakia/tests/mocks/server.py @@ -47,7 +47,8 @@ class MockServer(): self.handler = self.app.make_handler( keep_alive_on=False, - access_log=log.access_logger) + access_log=log.access_logger, + ) self.port = self.find_unused_port() @@ -95,4 +96,7 @@ class MockServer(): self.add_route('GET', '/network/peering', bma_peering_generator(self.port)) - return srv, self.port, url \ No newline at end of file + return srv, self.port, url + + async def close(self): + await self.handler.finish_connections() \ No newline at end of file