Skip to content
Snippets Groups Projects
Commit 2bd18eac authored by inso's avatar inso
Browse files

Fix bug when opening transfer dialog

parent e9956d52
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
dialog = TransferMoneyDialog(self.app,
self.app.current_account,
self.password_asker)
dialog.accepted.connect(self.refresh_wallets)
if dialog.exec_() == QDialog.Accepted:
self.community_view.tab_history.table_history.model().sourceModel().refresh_transfers()
......
......@@ -149,3 +149,9 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
def recipient_mode_changed(self, pubkey_toggled):
self.edit_pubkey.setEnabled(pubkey_toggled)
self.combo_contact.setEnabled(not pubkey_toggled)
def async_exec(self):
future = asyncio.Future()
self.finished.connect(lambda r: future.set_result(r))
self.open()
return future
......@@ -84,7 +84,6 @@ class TestIdentitiesTable(unittest.TestCase):
identities_tab.close()
future.set_result(True)
@asyncio.coroutine
def exec_test():
yield from asyncio.sleep(1)
......
import sys
import unittest
import asyncio
import quamash
import time
import logging
from ucoinpy.documents.peer import BMAEndpoint as PyBMAEndpoint
from PyQt5.QtWidgets import QDialog, QDialogButtonBox
from PyQt5.QtCore import QLocale, Qt
from PyQt5.QtTest import QTest
from cutecoin.tests.mocks.bma import nice_blockchain
from cutecoin.tests.mocks.access_manager import MockNetworkAccessManager
from cutecoin.core.registry.identities import IdentitiesRegistry
from cutecoin.gui.transfer import TransferMoneyDialog
from cutecoin.gui.password_asker import PasswordAskerDialog
from cutecoin.core.app import Application
from cutecoin.core import Account, Community, Wallet
from cutecoin.core.net import Network, Node
from cutecoin.core.net.endpoint import BMAEndpoint
from cutecoin.core.net.api.bma.access import BmaAccess
from cutecoin.tests import get_application
from cutecoin.core.net.api import bma as qtbma
class TestTransferDialog(unittest.TestCase):
def setUp(self):
self.qapplication = get_application()
self.network_manager = MockNetworkAccessManager()
QLocale.setDefault(QLocale("en_GB"))
self.lp = quamash.QEventLoop(self.qapplication)
asyncio.set_event_loop(self.lp)
self.identities_registry = IdentitiesRegistry({})
self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry)
self.application.preferences['notifications'] = False
self.endpoint = BMAEndpoint(PyBMAEndpoint("", "127.0.0.1", "", 50000))
self.node = Node(self.network_manager, "test_currency", [self.endpoint],
"", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk",
qtbma.blockchain.Block.null_value, Node.ONLINE,
time.time(), {}, "ucoin", "0.14.0", 0)
self.network = Network.create(self.network_manager, self.node)
self.bma_access = BmaAccess.create(self.network)
self.community = Community("test_currency", self.network, self.bma_access)
self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
"Wallet 1", self.identities_registry)
# Salt/password : "testcutecoin/testcutecoin"
# Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
self.account = Account("testcutecoin", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
"john", [self.community], [self.wallet], [], self.identities_registry)
self.password_asker = PasswordAskerDialog(self.account)
self.password_asker.password = "testcutecoin"
self.password_asker.remember = True
def tearDown(self):
try:
self.lp.close()
finally:
asyncio.set_event_loop(None)
def test_transfer_nice_community(self):
mock = nice_blockchain.get_mock()
time.sleep(2)
logging.debug(mock.pretend_url)
self.network_manager.set_mock_path(mock.pretend_url)
transfer_dialog = TransferMoneyDialog(self.application,
self.account,
self.password_asker)
@asyncio.coroutine
def open_dialog(certification_dialog):
result = yield from certification_dialog.async_exec()
self.assertEqual(result, QDialog.Rejected)
def close_dialog():
if transfer_dialog.isVisible():
transfer_dialog.close()
@asyncio.coroutine
def exec_test():
yield from asyncio.sleep(1)
self.assertEqual(transfer_dialog.button_box.button(QDialogButtonBox.Ok).text(), "&Ok")
QTest.mouseClick(transfer_dialog.radio_pubkey, Qt.LeftButton)
QTest.keyClicks(transfer_dialog.edit_pubkey, "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn")
QTest.mouseClick(transfer_dialog.button_box.button(QDialogButtonBox.Cancel), Qt.LeftButton)
self.lp.call_later(15, close_dialog)
asyncio.async(exec_test())
self.lp.run_until_complete(open_dialog(transfer_dialog))
if __name__ == '__main__':
logging.basicConfig(stream=sys.stderr)
logging.getLogger().setLevel(logging.DEBUG)
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment