From 6cb63079b4473a52747844fe17389a3209e27447 Mon Sep 17 00:00:00 2001 From: inso <insomniak.fr@gmaiL.com> Date: Sat, 30 Jul 2016 10:41:36 +0200 Subject: [PATCH] Squashed commit of the following: commit 65cf5a6fd7a874a2e77b56c1eb2dd74600d78f24 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 10:34:04 2016 +0200 Remove pyenv-virtualenv calls commit 3a08b35fe7369f73d73d1081b47677bd2e40090d Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 10:11:33 2016 +0200 Fix paths on linux commit 0c7368c3b5df981017b0675691500d52a75c7dd8 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 09:53:39 2016 +0200 Fix tests with new quamash commit d755609f71f5cbe1f7364107743c1d1d16624dd0 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 09:04:18 2016 +0200 Python 3.5.2 commit 2eff54c8c266cac017f5b89cb02b7f9a06c77e30 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 08:59:36 2016 +0200 Remove travis pyenv commit cc2c5010236928a1426423fde81af6b979402232 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 08:55:56 2016 +0200 Install pyenv differently commit 8eb0ab17639f3d5086dd9ac5160416ab17f5b457 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 08:48:37 2016 +0200 Update python-build definitions commit d67aaa1d146c9ca2b3a6ba446f749813ebafeda0 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 08:46:40 2016 +0200 Try to update commit 48144ae208b1d5bbda8271b9aa382f129e4e006c Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 08:34:21 2016 +0200 Try to fix linux build commit a8a34fb07b43d2b845fdb9ccce6a05df00a93edb Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 01:06:58 2016 +0200 Fix coverage run on osx commit 6dbe04dcb473cb59416614d04ae7cd77e292d0c5 Author: inso <insomniak.fr@gmaiL.com> Date: Sat Jul 30 00:48:58 2016 +0200 Export path on osx commit fb437f913af9705e254556153b30f0f623e7088b Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 23:59:35 2016 +0200 Display travis path commit 16a7352859a1051f4018f4b4e3ec79685deb8572 Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 23:40:33 2016 +0200 Fix sip path commit 56d6881d235e7c2b84a6c978d2899dde018344ae Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 23:29:22 2016 +0200 Remove some checks commit 692835aab9ab02833ce76a7b76337772bf3b80bd Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 22:51:46 2016 +0200 Try to remove all sakia-env commit face745b4ab1f91ee0f2ef9e9108eed1c37dfc3d Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 22:33:46 2016 +0200 Fix sakia-env commit 81a6f32e955e64d0e76b06374b2897cde8445daa Author: inso <insomniak.fr@gmaiL.com> Date: Fri Jul 29 21:45:47 2016 +0200 Try with pyenv in shell commit 91de5cbc7cc6fa53540c3e0fa84c6f5597447f47 Author: Insoleet <insomniak.fr@gmail.com> Date: Tue Jul 26 13:59:31 2016 +0200 Test with venv commit edfe603bd5e670d1eb4d478947173313eb1290f6 Author: Insoleet <insomniak.fr@gmail.com> Date: Tue Jul 26 12:16:44 2016 +0200 Python 3.5.1 commit e32afe1d79278ea3d6e226b0f1e40effb1447a3b Author: inso <insomniak.fr@gmaiL.com> Date: Mon Jul 25 21:07:52 2016 +0200 Python 3.5 commit eb854f8c8ea14c3b92ae9b9343bdaaea2906d609 Author: inso <insomniak.fr@gmaiL.com> Date: Sun Jul 24 09:30:06 2016 +0200 Version 3.5.1 commit 9c2d1a4664d79c62911f057206e457f67763ae60 Author: inso <insomniak.fr@gmaiL.com> Date: Sun Jul 24 09:21:37 2016 +0200 Fix travis commit bb600df9a1903490a10cabecefbb0a75104f6abd Author: inso <insomniak.fr@gmaiL.com> Date: Sun Jul 24 09:07:18 2016 +0200 Fix pyuic5 interpreter commit b2a72ca57ababeb6a5e2ba1785e61244fe6f68d0 Author: inso <insomniak.fr@gmaiL.com> Date: Sun Jul 24 08:26:35 2016 +0200 Fix build --- .travis.yml | 2 +- ci/travis/after_success.sh | 3 +- ci/travis/before_install.sh | 123 +++++++++--------- ci/travis/build.sh | 10 +- ci/travis/test.sh | 11 +- requirements.txt | 2 +- .../certification/test_certification.py | 1 + .../identities_tab/test_identities_table.py | 2 +- .../main_window/test_main_window_dialogs.py | 29 ++--- .../test_add_community.py | 7 +- .../functional/transfer/test_transfer.py | 1 + .../tests/functional/wot_tab/test_wot_tab.py | 1 + src/sakia/tests/mocks/server.py | 8 +- 13 files changed, 108 insertions(+), 92 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc8add0e..56a2d911 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 cb2acfb7..cb564e2d 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 e115b6e5..4a7ac805 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 0235b7f4..4210041e 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 23b92d82..25e05bd4 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 847ac1a6..145df061 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 35b214c1..b836a9b8 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 f7855a2a..c88876b6 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 422f9ded..ed9157a9 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 256dcba7..28b6da2b 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 6f83afb8..ad8df3cf 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 1beeddb0..3eb15fc3 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 38af9e96..14bb1317 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 -- GitLab