Skip to content
Snippets Groups Projects
Commit 7ca60a1c authored by inso's avatar inso
Browse files

Test opening wot_tab + account not None

parent cd887ad4
No related branches found
No related tags found
No related merge requests found
...@@ -207,6 +207,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -207,6 +207,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
""" """
Reset graph scene to wallet identity Reset graph scene to wallet identity
""" """
if self.account:
self.draw_graph( self.draw_graph(
self.account.identity(self.community) self.account.identity(self.community)
) )
...@@ -215,7 +216,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -215,7 +216,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
""" """
Refresh graph scene to current metadata Refresh graph scene to current metadata
""" """
if self._current_identity != None: if self._current_identity:
self.draw_graph(self._current_identity) self.draw_graph(self._current_identity)
else: else:
self.reset() self.reset()
......
__author__ = 'inso'
import sys
import unittest
import asyncio
import quamash
import logging
import time
from ucoinpy.documents.peer import BMAEndpoint as PyBMAEndpoint
from PyQt5.QtWidgets import QDialog
from PyQt5.QtCore import QLocale, Qt
from PyQt5.QtTest import QTest
from cutecoin.core.net.api import bma as qtbma
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
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
class TestIdentitiesTable(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_empty_wot_tab(self):
mock = nice_blockchain.get_mock()
time.sleep(2)
logging.debug(mock.pretend_url)
self.network_manager.set_mock_path(mock.pretend_url)
wot_tab = WotTabWidget(self.application)
future = asyncio.Future()
def open_widget():
wot_tab.show()
return future
@asyncio.coroutine
def async_open_widget():
yield from open_widget()
def close_dialog():
if wot_tab.isVisible():
wot_tab.close()
future.set_result(True)
@asyncio.coroutine
def exec_test():
yield from asyncio.sleep(1)
self.assertTrue(wot_tab.isVisible())
self.lp.call_soon(close_dialog)
asyncio.async(exec_test())
self.lp.call_later(15, close_dialog)
self.lp.run_until_complete(async_open_widget())
mock.delete_mock()
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.
Please register or to comment