diff --git a/lib/ucoinpy/api/bma/__init__.py b/lib/ucoinpy/api/bma/__init__.py index 464d65613523d4364e4de9698c4c824e7b81f301..b83875b77dca9aef406040923c15e2f2baabddd9 100644 --- a/lib/ucoinpy/api/bma/__init__.py +++ b/lib/ucoinpy/api/bma/__init__.py @@ -131,10 +131,6 @@ class API(object): response = yield from asyncio.wait_for( aiohttp.post(self.reverse_url(path), data=kwargs, headers=self.headers), timeout=15) - - if response.status != 200: - raise ValueError('status code != 200 => %d (%s)' % (response.status, (yield from (response.text())))) - return response from . import network, blockchain, tx, wot, node, ud diff --git a/lib/ucoinpy/api/bma/blockchain/__init__.py b/lib/ucoinpy/api/bma/blockchain/__init__.py index 8edd830d857737fa4e104d9e4d7b9ed555efa9e9..8e465ec99ea2b8d48413f263d093032dda3115fc 100644 --- a/lib/ucoinpy/api/bma/blockchain/__init__.py +++ b/lib/ucoinpy/api/bma/blockchain/__init__.py @@ -44,7 +44,7 @@ class Membership(Blockchain): assert 'membership' in kwargs r = yield from self.requests_post('/membership', **kwargs) - return (yield from r.text()) + return r def __get__(self, **kwargs): assert self.search is not None @@ -77,7 +77,7 @@ class Block(Blockchain): assert 'signature' in kwargs r = yield from self.requests_post('/block', **kwargs) - return (yield from r.text()) + return r class Current(Blockchain): diff --git a/lib/ucoinpy/api/bma/network/peering/__init__.py b/lib/ucoinpy/api/bma/network/peering/__init__.py index 8150cec1ac6b6e8cb7245560fc8f0f0d664937f9..36ca7915ff52b9ef7097ef7bb55be9f56bdf55ea 100644 --- a/lib/ucoinpy/api/bma/network/peering/__init__.py +++ b/lib/ucoinpy/api/bma/network/peering/__init__.py @@ -40,7 +40,7 @@ class Peers(Base): assert 'signature' in kwargs r = yield from self.requests_post('/peers', **kwargs) - return (yield from r.json()) + return r class Status(Base): @@ -51,4 +51,4 @@ class Status(Base): assert 'signature' in kwargs r = yield from self.requests_post('/status', **kwargs) - return (yield from r.json()) + return r diff --git a/lib/ucoinpy/api/bma/tx/__init__.py b/lib/ucoinpy/api/bma/tx/__init__.py index 8199d2d8d49a56016424c14b30a653f7211b5f5b..23ba91db03fc371febd6c2cb75e869f82342e3c6 100644 --- a/lib/ucoinpy/api/bma/tx/__init__.py +++ b/lib/ucoinpy/api/bma/tx/__init__.py @@ -45,7 +45,7 @@ class Process(Tx): assert 'transaction' in kwargs r = yield from self.requests_post('/process', **kwargs) - return (yield from r.text()) + return r class Sources(Tx): diff --git a/lib/ucoinpy/api/bma/wot/__init__.py b/lib/ucoinpy/api/bma/wot/__init__.py index ca9c97bcab3433eda75a28fc17c4d3b8b5d8de05..83fd51848909b2f1563043ff89e5203a10ff231a 100644 --- a/lib/ucoinpy/api/bma/wot/__init__.py +++ b/lib/ucoinpy/api/bma/wot/__init__.py @@ -35,7 +35,7 @@ class Add(WOT): assert 'other' in kwargs r = yield from self.requests_post('/add', **kwargs) - return (yield from r.text()) + return r class Revoke(WOT): @@ -46,7 +46,7 @@ class Revoke(WOT): assert 'self_' in kwargs r = yield from self.requests_post('/revoke', **kwargs) - return (yield from r.text()) + return r class Lookup(WOT): diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 93d3f9492032c3510f1dbbd687ebce6c30311f59..421c7cfa0d9ef6f033318661812008facfefb09b 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -34,11 +34,6 @@ class Account(QObject): loading_progressed = pyqtSignal(int, int) loading_finished = pyqtSignal(list) wallets_changed = pyqtSignal() - membership_broadcasted = pyqtSignal() - certification_broadcasted = pyqtSignal() - selfcert_broadcasted = pyqtSignal() - revoke_broadcasted = pyqtSignal() - broadcast_error = pyqtSignal(int, str) def __init__(self, salt, pubkey, name, communities, wallets, contacts, identities_registry): """ @@ -295,19 +290,19 @@ class Account(QObject): key = SigningKey(self.salt, password) selfcert.sign([key]) logging.debug("Key publish : {0}".format(selfcert.signed_raw())) - try: - error = 0 - replies = yield from community.bma_access.broadcast(bma.wot.Add, {}, {'pubkey': self.pubkey, + + responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, {'pubkey': self.pubkey, 'self_': selfcert.signed_raw(), 'other': {}}) - except ValueError as e: - error += 1 - error_msg = str(e) - finally: - if error < len(replies): - self.selfcert_broadcasted.emit() + result = (False, "") + for r in responses: + if r.status == 200: + result = (True, (yield from r.json())) + elif not result[0]: + result = (False, (yield from r.text())) else: - self.broadcast_error.emit(0, error_msg) + yield from r.text() + return result @asyncio.coroutine def send_membership(self, password, community, mstype): @@ -332,18 +327,17 @@ class Account(QObject): key = SigningKey(self.salt, password) membership.sign([key]) logging.debug("Membership : {0}".format(membership.signed_raw())) - try: - error = 0 - replies = yield from community.bma_access.broadcast(bma.blockchain.Membership, {}, - {'membership': membership.signed_raw()}) - except ValueError as e: - error += 1 - error_msg = str(e) - finally: - if error < len(replies): - self.membership_broadcasted.emit() + responses = yield from community.bma_access.broadcast(bma.blockchain.Membership, {}, + {'membership': membership.signed_raw()}) + result = (False, "") + for r in responses: + if r.status == 200: + result = (True, (yield from r.json())) + elif not result[0]: + result = (False, (yield from r.text())) else: - self.broadcast_error.emit(0, error_msg) + yield from r.text() + return result @asyncio.coroutine def certify(self, password, community, pubkey): @@ -371,17 +365,16 @@ class Account(QObject): 'self_': selfcert.signed_raw(), 'other': "{0}\n".format(certification.inline())} logging.debug("Posted data : {0}".format(data)) - try: - error = 0 - responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, data) - except ValueError as e: - error += 1 - error_msg = str(e) - finally: - if error < len(responses): - self.certification_broadcasted.emit() + responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, data) + result = (False, "") + for r in responses: + if r.status == 200: + result = (True, (yield from r.json())) + elif not result[0]: + result = (False, (yield from r.text())) else: - self.broadcast_error.emit(0, error_msg) + yield from r.text() + return result @asyncio.coroutine def revoke(self, password, community): @@ -408,17 +401,16 @@ class Account(QObject): 'sig': revocation.signatures[0] } logging.debug("Posted data : {0}".format(data)) - try: - error = 0 - replies = yield from community.broadcast(bma.wot.Revoke, {}, data) - except ValueError as e: - error += 1 - error_msg = str(e) - finally: - if error < len(replies): - self.revoke_broadcasted.emit() + responses = yield from community.broadcast(bma.wot.Revoke, {}, data) + result = (False, "") + for r in responses: + if r.status == 200: + result = (True, (yield from r.json())) + elif not result[0]: + result = (False, (yield from r.text())) else: - self.broadcast_error.emit(error_msg) + yield from r.text() + return result def start_coroutines(self): for c in self.communities: diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index 724b74183ec7b94e4eca2e03b71c107d528ec69b..5c473575beb15a8f8a78ec5dd9f4e2cf6a60ef53 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -226,7 +226,7 @@ class Application(QObject): account_name, 'properties') with open(account_path, 'r') as json_data: data = json.load(json_data) - account = Account.load(data, self._network_manager, self._identities_registry) + account = Account.load(data, self._identities_registry) self.load_cache(account) self.accounts[account_name] = account diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index cad27a826c4521ec245ebb5fd39128ad322e9b52..b4defa7a5e119cc1bb45e0adb337a656aa931995 100644 --- a/src/cutecoin/core/transfer.py +++ b/src/cutecoin/core/transfer.py @@ -108,26 +108,25 @@ class Transfer(QObject): :param txdoc: A transaction ucoinpy object :param community: The community target of the transaction """ - try: - error = 0 - replies = yield from community.bma_access.broadcast(bma.tx.Process, - post_args={'transaction': txdoc.signed_raw()}) - self.state = Transfer.AWAITING - self.hash = hashlib.sha1(txdoc.signed_raw().encode("ascii")).hexdigest().upper() - blockid = yield from community.blockid() - block = yield from community.bma_access.future_request(bma.blockchain.Block, - req_args={'number': blockid['number']}) - if block != bma.blockchain.Block.null_value: - self._metadata['block'] = blockid['number'] - self._metadata['time'] = block['medianTime'] - except ValueError as e: - error += 1 - error_msg = str(e) - finally: - if error < len(replies): - self.transfer_broadcasted.emit(self.metadata['receiver_uid']) + responses = yield from community.bma_access.broadcast(bma.tx.Process, + post_args={'transaction': txdoc.signed_raw()}) + self.state = Transfer.AWAITING + self.hash = hashlib.sha1(txdoc.signed_raw().encode("ascii")).hexdigest().upper() + blockid = yield from community.blockid() + block = yield from community.bma_access.future_request(bma.blockchain.Block, + req_args={'number': blockid['number']}) + self._metadata['block'] = blockid['number'] + self._metadata['time'] = block['medianTime'] + result = (False, "") + for r in responses: + if r.status == 200: + result = (True, (yield from r.json())) + elif not result[0]: + result = (False, (yield from r.text())) else: - self.broadcast_error.emit(0, error_msg) + yield from r.text() + + return result def check_registered(self, txhash, block_number, time, data_validation): """ diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 22a7bcb7aa0141c79bd39de377bd1f36f2625f9d..4c81da5f5cf6eb0acf2b2d88bc79b1049ee2c77d 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -26,8 +26,6 @@ class Wallet(QObject): """ refresh_progressed = pyqtSignal(int, int, str) refresh_finished = pyqtSignal(list) - transfer_broadcasted = pyqtSignal(str) - broadcast_error = pyqtSignal(int, str) def __init__(self, walletid, pubkey, name, identities_registry): """ @@ -272,9 +270,7 @@ class Wallet(QObject): tx.sign([key]) logging.debug("Transaction : {0}".format(tx.signed_raw())) - transfer.transfer_broadcasted.connect(self.transfer_broadcasted) - transfer.broadcast_error.connect(self.broadcast_error) - yield from transfer.send(tx, community) + return (yield from transfer.send(tx, community)) @asyncio.coroutine def future_sources(self, community): diff --git a/src/cutecoin/gui/certification.py b/src/cutecoin/gui/certification.py index 4bc18e893db1be7e43ae2fd4c91e505fac011e48..ca133cad83e7a0a1736e0e32c831def629b6b073 100644 --- a/src/cutecoin/gui/certification.py +++ b/src/cutecoin/gui/certification.py @@ -35,14 +35,18 @@ class CertificationDialog(QDialog, Ui_CertificationDialog): for contact in certifier.contacts: self.combo_contact.addItem(contact['name']) - @staticmethod - def certify_identity(app, account, password_asker, community, identity): - dialog = CertificationDialog(app, account, password_asker) + @classmethod + @asyncify + @asyncio.coroutine + def certify_identity(cls, app, account, password_asker, community, identity): + dialog = cls(app, account, password_asker) dialog.combo_community.setCurrentText(community.name) dialog.edit_pubkey.setText(identity.pubkey) dialog.radio_pubkey.setChecked(True) - return dialog.exec_() + yield from dialog.async_exec() + @asyncify + @asyncio.coroutine def accept(self): if self.radio_contact.isChecked(): index = self.combo_contact.currentIndex() @@ -50,34 +54,20 @@ class CertificationDialog(QDialog, Ui_CertificationDialog): else: pubkey = self.edit_pubkey.text() - password = self.password_asker.exec_() + password = yield from self.password_asker.async_exec() if password == "": return - QApplication.setOverrideCursor(Qt.WaitCursor) - self.account.certification_broadcasted.connect(lambda: self.certification_sent(pubkey, - self.community.currency)) - self.account.broadcast_error.connect(self.handle_error) - - asyncio.async(self.account.certify(password, self.community, pubkey)) - - def certification_sent(self, pubkey, currency): - toast.display(self.tr("Certification"), - self.tr("Success certifying {0} from {1}").format(pubkey, currency)) - self.account.certification_broadcasted.disconnect() - self.account.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() - super().accept() - - @pyqtSlot(int, str) - def handle_error(self, error_code, text): - if self.app.preferences['notifications']: - toast.display(self.tr("Error"), self.tr("{0} : {1}".format(error_code, text))) - #else: - # QMessageBox.Critical(self, self.tr("Error", self.tr("{0} : {1}".format(error_code, text)))) - self.account.certification_broadcasted.disconnect() - self.account.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() + result = yield from self.account.certify(password, self.community, pubkey) + if result[0]: + if self.app.preferences['notifications']: + toast.display(self.tr("Success"), self.tr("Success sending certification")) + QApplication.restoreOverrideCursor() + super().accept() + else: + if self.app.preferences['notifications']: + toast.display(self.tr("Error broadcasting"), self.tr("Could not broadcast certification")) + QApplication.restoreOverrideCursor() def change_current_community(self, index): self.community = self.account.communities[index] diff --git a/src/cutecoin/gui/community_view.py b/src/cutecoin/gui/community_view.py index 7ca3c35c3e9c186971a9dbc69327b0aba5d26b3e..582768cea4e94b8b38a904e41727b3d34ce6fa7f 100644 --- a/src/cutecoin/gui/community_view.py +++ b/src/cutecoin/gui/community_view.py @@ -88,18 +88,9 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): def change_account(self, account, password_asker): self.cancel_once_tasks() - if self.account: - self.account.broadcast_error.disconnect(self.handle_broadcast_error) - self.account.membership_broadcasted.disconnect(self.handle_membership_broadcasted) - self.account.selfcert_broadcasted.disconnect(self.handle_selfcert_broadcasted) self.account = account - if self.account: - self.account.broadcast_error.connect(self.handle_broadcast_error) - self.account.membership_broadcasted.connect(self.handle_membership_broadcasted) - self.account.selfcert_broadcasted.connect(self.handle_selfcert_broadcasted) - self.password_asker = password_asker self.tab_wot.change_account(account, self.password_asker) self.tab_identities.change_account(account, self.password_asker) @@ -254,11 +245,19 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): self.tab_history.table_history.model().sourceModel().refresh_transfers() self.tab_history.refresh_balance() - def send_membership_demand(self): - password = self.password_asker.exec_() + @asyncify + @asyncio.coroutine + def send_membership_demand(self, checked=False): + password = yield from self.password_asker.async_exec() if self.password_asker.result() == QDialog.Rejected: return - asyncio.async(self.account.send_membership(password, self.community, 'IN')) + result = yield from self.account.send_membership(password, self.community, 'IN') + if result[0]: + if self.app.preferences['notifications']: + toast.display(self.tr("Membership"), self.tr("Success sending Membership demand")) + else: + if self.app.preferences['notifications']: + toast.display(self.tr("Membership"), result[1]) def send_membership_leaving(self): reply = QMessageBox.warning(self, self.tr("Warning"), @@ -311,12 +310,6 @@ Revoking your UID can only success if it is not already validated by the network asyncio.async(self.account.revoke(password, self.community)) - def handle_membership_broadcasted(self): - if self.app.preferences['notifications']: - toast.display(self.tr("Membership"), self.tr("Success sending Membership demand")) - else: - QMessageBox.information(self, self.tr("Membership"), self.tr("Success sending Membership demand")) - def handle_revoke_broadcasted(self): if self.app.preferences['notifications']: toast.display(self.tr("Revoke"), self.tr("Success sending Revoke demand")) diff --git a/src/cutecoin/gui/password_asker.py b/src/cutecoin/gui/password_asker.py index 04a7a4f92b9e262bbaafc47500f3da5ea492ded3..32daee1a3d8eeb490fab9f01de1ebd955f14cea3 100644 --- a/src/cutecoin/gui/password_asker.py +++ b/src/cutecoin/gui/password_asker.py @@ -29,7 +29,7 @@ class PasswordAskerDialog(QDialog, Ui_PasswordAskerDialog): self.password = "" self.remember = False - def future_exec(self): + def async_exec(self): future = asyncio.Future() if not self.remember: def future_show(): diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 8a102051e526991b89ee72660115920f60522682..2dd0cc1933f6ea84db2bbc8c61abec3ed224a65d 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -86,13 +86,23 @@ class StepPageInit(Step): community = Community.create(self.node) identity = yield from self.app.identities_registry.future_find(self.account.pubkey, community) if identity.blockchain_state == BlockchainState.NOT_FOUND: - password = yield from self.password_asker.future_exec() + password = yield from self.password_asker.async_exec() if self.password_asker.result() == QDialog.Rejected: return self.config_dialog.label_error.setText(self.tr("Broadcasting identity...")) - self.account.selfcert_broadcasted.connect(self.handle_broadcast) - self.account.broadcast_error.connect(self.handle_error) - yield from self.account.send_selfcert(password, community) + result = yield from self.account.send_selfcert(password, community) + if result[0]: + if self.app.preferences['notifications']: + toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network")) + QApplication.restoreOverrideCursor() + self.config_dialog.next() + else: + self.config_dialog.label_error.setText(self.tr("Error") + " " + \ + self.tr("{0}".format(result[1]))) + if self.app.preferences['notifications']: + toast.display(self.tr("Error"), self.tr("{0}".format(result[1]))) + QApplication.restoreOverrideCursor() + self.config_dialog.community = community else: self.config_dialog.label_error.setText(self.tr("Pubkey already exists on the network")) @@ -104,31 +114,6 @@ class StepPageInit(Step): logging.debug("Check node") asyncio.async(self.coroutine_check_register()) - @pyqtSlot(int, str) - def handle_broadcast(self): - if self.app.preferences['notifications']: - toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network")) - # Disabled : https://github.com/harvimt/quamash/issues/41 - # else: - # QMessageBox.information(self, self.tr("UID broadcast"), self.tr("Identity broadcasted to the network")) - self.account.selfcert_broadcasted.disconnect() - self.account.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() - self.config_dialog.next() - - @pyqtSlot(int, str) - def handle_error(self, error_code, text): - self.config_dialog.label_error.setText(self.tr("Error") + " " + \ - self.tr("{0} : {1}".format(error_code, text))) - if self.app.preferences['notifications']: - toast.display(self.tr("Error"), self.tr("{0} : {1}".format(error_code, text))) - # Disabled : https://github.com/harvimt/quamash/issues/41 - # else: - # QMessageBox.critical(self, self.tr("Error"), self.tr("{0} : {1}".format(error_code, text))) - self.account.selfcert_broadcasted.disconnect() - self.account.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() - def is_valid(self): return self.node is not None diff --git a/src/cutecoin/gui/transfer.py b/src/cutecoin/gui/transfer.py index 1258314f18d4f0e4531a12b3c8f4545f51573c3d..e2b8bb7c0ad4da746c18256c6edcb5226f13ba53 100644 --- a/src/cutecoin/gui/transfer.py +++ b/src/cutecoin/gui/transfer.py @@ -55,14 +55,18 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): self.radio_contact.setEnabled(False) self.radio_pubkey.setChecked(True) - @staticmethod - def send_money_to_identity(app, account, password_asker, community, identity): - dialog = TransferMoneyDialog(app, account, password_asker) + @classmethod + @asyncify + @asyncio.coroutine + def send_money_to_identity(cls, app, account, password_asker, community, identity): + dialog = cls(app, account, password_asker) dialog.edit_pubkey.setText(identity.pubkey) dialog.combo_community.setCurrentText(community.name) dialog.radio_pubkey.setChecked(True) - return dialog.exec() + yield from dialog.async_exec() + @asyncify + @asyncio.coroutine def accept(self): comment = self.edit_message.text() @@ -74,44 +78,31 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): amount = self.spinbox_amount.value() if not amount: + return + """ QMessageBox.critical(self, self.tr("Money transfer"), self.tr("No amount. Please give the transfert amount"), QMessageBox.Ok) - return + return""" - password = self.password_asker.exec_() + password = yield from self.password_asker.async_exec() if self.password_asker.result() == QDialog.Rejected: return QApplication.setOverrideCursor(Qt.WaitCursor) QApplication.processEvents() - self.wallet.transfer_broadcasted.connect(self.money_sent) - self.wallet.broadcast_error.connect(self.handle_error) - asyncio.async(self.wallet.send_money(self.account.salt, password, self.community, - recipient, amount, comment)) - - @pyqtSlot(str) - def money_sent(self, receiver_uid): - if self.app.preferences['notifications']: - toast.display(self.tr("Transfer"), - self.tr("Success sending money to {0}").format(receiver_uid)) - else: - QMessageBox.information(self, self.tr("Transfer"), - self.tr("Success sending money to {0}").format(receiver_uid)) - self.wallet.transfer_broadcasted.disconnect() - self.wallet.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() - super().accept() - - @pyqtSlot(int, str) - def handle_error(self, error_code, text): - if self.app.preferences['notifications']: - toast.display(self.tr("Error"), self.tr("{0} : {1}".format(error_code, text))) + result = yield from self.wallet.send_money(self.account.salt, password, self.community, + recipient, amount, comment) + if result[0]: + if self.app.preferences['notifications']: + toast.display(self.tr("Transfer"), + self.tr("Success sending money to {0}").format(recipient)) + QApplication.restoreOverrideCursor() + super().accept() else: - QMessageBox.critical(self, self.tr("Error"), self.tr("{0} : {1}".format(error_code, text))) - self.wallet.transfer_broadcasted.disconnect() - self.wallet.broadcast_error.disconnect(self.handle_error) - QApplication.restoreOverrideCursor() + if self.app.preferences['notifications']: + toast.display(self.tr("Error"), "{0}".format(result[1])) + QApplication.restoreOverrideCursor() @asyncify @asyncio.coroutine diff --git a/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py b/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py index bd120dbdd1a5c1ba823f011502d2185f1c1be85a..18bced162031179ed3bc3de6e9ba4161d73e2bc4 100644 --- a/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py +++ b/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py @@ -8,7 +8,6 @@ from ucoinpy.documents.peer import BMAEndpoint as PyBMAEndpoint 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.core.app import Application from cutecoin.core import Account, Community, Wallet diff --git a/src/cutecoin/tests/gui/certification/test_certification.py b/src/cutecoin/tests/gui/certification/test_certification.py index 2c75ddb7f9aa7aa7a80e4ace4cf128a80698cb88..3440e6786ad8c50a57afb63b98d1fc9bc490278e 100644 --- a/src/cutecoin/tests/gui/certification/test_certification.py +++ b/src/cutecoin/tests/gui/certification/test_certification.py @@ -11,7 +11,6 @@ from PyQt5.QtTest import QTest from ucoinpy.api.bma import API from cutecoin.tests.mocks.monkeypatch import pretender_reversed from cutecoin.tests.mocks.bma import init_new_community -from cutecoin.tests.mocks.access_manager import MockNetworkAccessManager from cutecoin.core.registry.identities import IdentitiesRegistry from cutecoin.gui.certification import CertificationDialog from cutecoin.gui.password_asker import PasswordAskerDialog diff --git a/src/cutecoin/tests/gui/identities_tab/test_identities_table.py b/src/cutecoin/tests/gui/identities_tab/test_identities_table.py index b5e8c936906b98afc860eedf28861f688fa6cb53..830f2ec70331cd4f43faa354f5714a4b11b2106b 100644 --- a/src/cutecoin/tests/gui/identities_tab/test_identities_table.py +++ b/src/cutecoin/tests/gui/identities_tab/test_identities_table.py @@ -12,7 +12,6 @@ from ucoinpy.api import bma from ucoinpy.api.bma import API from cutecoin.tests.mocks.monkeypatch import pretender_reversed 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.identities_tab import IdentitiesTabWidget from cutecoin.gui.password_asker import PasswordAskerDialog diff --git a/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py b/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py index 887ff99166ac1ddc1aef23fdf62bf3fbe13639ce..9f35dad5bd88af76083cc4af098c973cc59c2908 100644 --- a/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py +++ b/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py @@ -7,7 +7,6 @@ from PyQt5.QtWidgets import QDialog from PyQt5.QtCore import QLocale, Qt from PyQt5.QtTest import QTest from cutecoin.tests.mocks.bma import new_blockchain -from cutecoin.tests.mocks.access_manager import MockNetworkAccessManager from cutecoin.core.registry.identities import IdentitiesRegistry from cutecoin.gui.process_cfg_account import ProcessConfigureAccount from cutecoin.gui.password_asker import PasswordAskerDialog diff --git a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py index c7d112e5f20c4e274e501dbaf9b2dee31585e664..5d5a00ab07c6a5f316f510824912ab39b660f510 100644 --- a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py +++ b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py @@ -10,7 +10,6 @@ from PyQt5.QtTest import QTest from ucoinpy.api.bma import API from cutecoin.tests.mocks.monkeypatch import pretender_reversed from cutecoin.tests.mocks.bma import new_blockchain, nice_blockchain -from cutecoin.tests.mocks.access_manager import MockNetworkAccessManager from cutecoin.core.registry.identities import IdentitiesRegistry from cutecoin.gui.process_cfg_community import ProcessConfigureCommunity from cutecoin.gui.password_asker import PasswordAskerDialog diff --git a/src/cutecoin/tests/gui/transfer/test_transfer.py b/src/cutecoin/tests/gui/transfer/test_transfer.py index e97c8790f247769799e3f34f0c432660880b3a82..fc69bd58fa8a7b95ad2f959cf6ff9850cc47ade4 100644 --- a/src/cutecoin/tests/gui/transfer/test_transfer.py +++ b/src/cutecoin/tests/gui/transfer/test_transfer.py @@ -11,7 +11,6 @@ from PyQt5.QtTest import QTest from ucoinpy.api.bma import API from cutecoin.tests.mocks.monkeypatch import pretender_reversed 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 diff --git a/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py b/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py index 72e1fc8a2d52e054d5d0ad416d3bd068826211cc..b74ac0e2e879a007f2bff99481d8ad8fbbd0e04c 100644 --- a/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py +++ b/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py @@ -12,7 +12,6 @@ from ucoinpy.api import bma from ucoinpy.api.bma import API from cutecoin.tests.mocks.monkeypatch import pretender_reversed 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.wot_tab import WotTabWidget from cutecoin.gui.password_asker import PasswordAskerDialog diff --git a/src/cutecoin/tests/mocks/access_manager.py b/src/cutecoin/tests/mocks/access_manager.py deleted file mode 100644 index 754909841f6dd3e102e5a06d75d0beead89310c3..0000000000000000000000000000000000000000 --- a/src/cutecoin/tests/mocks/access_manager.py +++ /dev/null @@ -1,27 +0,0 @@ -from PyQt5.QtNetwork import QNetworkAccessManager -from PyQt5.QtCore import QUrl - -class MockNetworkAccessManager(QNetworkAccessManager): - def __init__(self): - super().__init__() - self.mock_path = "" - - def set_mock_path(self, mock_url): - url = QUrl(mock_url) - self.mock_path = url.path() - - def get(self, request): - url = request.url() - path = url.path() - path = self.mock_path + path - url.setPath(path) - request.setUrl(url) - return super().get(request) - - def post(self, request, post_data): - url = request.url() - path = url.path() - path = self.mock_path + path - url.setPath(path) - request.setUrl(url) - return super().post(request, post_data) \ No newline at end of file