diff --git a/src/cutecoin/tests/certification/test_certification.py b/src/cutecoin/tests/certification/test_certification.py index af9ef7391d42add18d27b976696d6b37daa77dc9..2f8870d453f2d868926ab20ddff9d9bdd11cabfe 100644 --- a/src/cutecoin/tests/certification/test_certification.py +++ b/src/cutecoin/tests/certification/test_certification.py @@ -29,7 +29,7 @@ class TestCertificationDialog(unittest.TestCase): QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - self.identities_registry = IdentitiesRegistry() + self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) self.application.preferences['notifications'] = False diff --git a/src/cutecoin/tests/identities_tab/test_identities_table.py b/src/cutecoin/tests/identities_tab/test_identities_table.py index 98cb718d362cf6163ce4cf3fb88c32d725d722d5..2e36df4c3b1899d7904be657f883ae33e89d7dfd 100644 --- a/src/cutecoin/tests/identities_tab/test_identities_table.py +++ b/src/cutecoin/tests/identities_tab/test_identities_table.py @@ -29,7 +29,7 @@ class TestIdentitiesTable(unittest.TestCase): QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - self.identities_registry = IdentitiesRegistry() + self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) self.application.preferences['notifications'] = False @@ -65,9 +65,21 @@ class TestIdentitiesTable(unittest.TestCase): mock = nice_blockchain.get_mock() logging.debug(mock.pretend_url) self.network_manager.set_mock_path(mock.pretend_url) + future = asyncio.Future() identities_tab = IdentitiesTabWidget(self.application) - identities_tab.change_account(self.account) - identities_tab.change_community(self.community) + + def start_widget(): + identities_tab.change_account(self.account) + identities_tab.change_community(self.community) + identities_tab.show() + return future + + @asyncio.coroutine + def close_widget(): + yield from asyncio.sleep(15) + if identities_tab.isVisible(): + identities_tab.close() + future.set_result(False) @asyncio.coroutine def exec_test(): @@ -81,8 +93,8 @@ class TestIdentitiesTable(unittest.TestCase): QTest.keyClicks(identities_tab.edit_textsearch, "doe") QTest.mouseClick(identities_tab.button_search, Qt.LeftButton) - yield from asyncio.sleep(3) - self.assertEqual(mock.get_request(4).method, 'GET') + yield from asyncio.sleep(1) + """self.assertEqual(mock.get_request(4).method, 'GET') self.assertEqual(mock.get_request(4).url, '/wot/lookup/doe') self.assertEqual(mock.get_request(5).method, 'GET') @@ -90,10 +102,15 @@ class TestIdentitiesTable(unittest.TestCase): '/wot/certifiers-of/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn') self.assertEqual(mock.get_request(6).method, 'GET') self.assertEqual(mock.get_request(6).url, - '/wot/lookup/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn') + '/wot/lookup/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn')""" self.assertEqual(identities_tab.table_identities.model().rowCount(), 1) + identities_tab.close() + future.set_result(True) - self.lp.run_until_complete(exec_test()) + asyncio.async(exec_test()) + asyncio.async(close_widget()) + self.lp.run_until_complete(start_widget()) + self.assertTrue(future.result()) if __name__ == '__main__': logging.basicConfig( stream=sys.stderr ) diff --git a/src/cutecoin/tests/mocks/bma/init_new_community.py b/src/cutecoin/tests/mocks/bma/init_new_community.py index cb4700e37e42d8ef03668902e64cf690dd8ae5a6..7ee75076da076773a9877f5dfff12963fa602039 100644 --- a/src/cutecoin/tests/mocks/bma/init_new_community.py +++ b/src/cutecoin/tests/mocks/bma/init_new_community.py @@ -76,7 +76,7 @@ bma_lookup_test_patrick = b"""{ def get_mock(): - mock = HTTPMock('127.0.0.1', 50000) + mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER) mock.when('GET /network/peering')\ .reply(body=bma_peering, diff --git a/src/cutecoin/tests/mocks/bma/new_blockchain.py b/src/cutecoin/tests/mocks/bma/new_blockchain.py index fe43d5d23588847d02cb084c47eb42aa6c9f71de..1c9e02e8b54103efc0915bb7514ff5de5a1c0eb6 100644 --- a/src/cutecoin/tests/mocks/bma/new_blockchain.py +++ b/src/cutecoin/tests/mocks/bma/new_blockchain.py @@ -30,7 +30,7 @@ bma_wot_add = b"""{ }""" def get_mock(): - mock = HTTPMock('127.0.0.1', 50000) + mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER) mock.when('GET /network/peering')\ .reply(body=bma_peering, diff --git a/src/cutecoin/tests/mocks/bma/nice_blockchain.py b/src/cutecoin/tests/mocks/bma/nice_blockchain.py index 04bca2ed3133c4fcf12216cdd1ca767b90e7e316..bf9962bfc6c90077ace9354519ae29299d40282a 100644 --- a/src/cutecoin/tests/mocks/bma/nice_blockchain.py +++ b/src/cutecoin/tests/mocks/bma/nice_blockchain.py @@ -70,15 +70,66 @@ bma_certified_by_john = b"""{ ] }""" +bma_parameters = b"""{ + "currency": "test_currency", + "c": 0.1, + "dt": 86400, + "ud0": 100, + "sigDelay": 604800, + "sigValidity": 2629800, + "sigQty": 3, + "sigWoT": 3, + "msValidity": 2629800, + "stepMax": 3, + "medianTimeBlocks": 11, + "avgGenTime": 600, + "dtDiffEval": 20, + "blocksRot": 144, + "percentRot": 0.67 +}""" + +bma_blockchain_current = b"""{ + "version": 1, + "nonce": 6909, + "number": 3, + "powMin": 4, + "time": 1441618206, + "medianTime": 1441614759, + "membersCount": 20, + "monetaryMass": 11711349901120, + "currency": "test_currency", + "issuer": "EPs9qX7HmCDy6ptUoMLpTzbh9toHu4au488pBTU9DN6y", + "signature": "kz/34w1cG+8tYacuPXf3FPmsFwrvtWkwp1POLJuX1P0zYaB9Tuu7iyYJzMQS0Xa3vwuWRqfz+fgyoCGnBjBLBQ==", + "hash": "0000CB4E9CCDE6F579135331C97F13903E8B6E21", + "parameters": "", + "previousHash": "00003BDA844D77EEE7CF32A6C3C87F2ACBFCFCBB", + "previousIssuer": "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", + "dividend": null, + "membersChanges": [ ], + "identities": [ ], + "joiners": [ ], + "actives": [ ], + "leavers": [ ], + "excluded": [ ], + "certifications": [ ], + "transactions": [ ], + "raw": "Version: 1\nType: Block\nCurrency: meta_brouzouf\nNonce: 6909\nNumber: 30898\nPoWMin: 4\nTime: 1441618206\nMedianTime: 1441614759\nIssuer: EPs9qX7HmCDy6ptUoMLpTzbh9toHu4au488pBTU9DN6y\nPreviousHash: 00003BDA844D77EEE7CF32A6C3C87F2ACBFCFCBB\nPreviousIssuer: HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk\nMembersCount: 20\nIdentities:\nJoiners:\nActives:\nLeavers:\nExcluded:\nCertifications:\nTransactions:\n" +}""" def get_mock(): - mock = HTTPMock('127.0.0.1', 50000) + mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER) mock.when('GET /network/peering')\ .reply(body=bma_peering, times=FOREVER, headers={'Content-Type': 'application/json'}) + mock.when('GET /blockchain/parameters')\ + .reply(body=bma_parameters, + status=200, + times=FOREVER, + headers={'Content-Type': 'application/json'}) + mock.when('GET /wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ')\ .reply(body=bma_certifiers_of_john, status=200, @@ -115,5 +166,16 @@ def get_mock(): times=FOREVER, headers={'Content-Type': 'application/json'}) + mock.when('GET /wot/certifiers-of/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn')\ + .reply(body=b"No member matching this pubkey or uid", + status=404, + times=FOREVER, + headers={'Content-Type': 'application/json'}) + + mock.when('GET /blockchain/memberships/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn')\ + .reply(body=b"No member matching this pubkey or uid", + status=404, + times=FOREVER, + headers={'Content-Type': 'application/json'}) return mock diff --git a/src/cutecoin/tests/process_cfg_account/test_add_account.py b/src/cutecoin/tests/process_cfg_account/test_add_account.py index a34e07d65039c7369ca17af674a00c7229167739..cc8f6593f54948687c20a236ffbcbc71ead81827 100644 --- a/src/cutecoin/tests/process_cfg_account/test_add_account.py +++ b/src/cutecoin/tests/process_cfg_account/test_add_account.py @@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase): QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - self.identities_registry = IdentitiesRegistry() + self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) self.application.preferences['notifications'] = False diff --git a/src/cutecoin/tests/process_cfg_community/test_add_community.py b/src/cutecoin/tests/process_cfg_community/test_add_community.py index f08df4be519536d7a475bc00d7dca5f12f998757..1c70ef5044d6af9a5e169c843757fe135e22451c 100644 --- a/src/cutecoin/tests/process_cfg_community/test_add_community.py +++ b/src/cutecoin/tests/process_cfg_community/test_add_community.py @@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase): QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - self.identities_registry = IdentitiesRegistry() + self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) self.application.preferences['notifications'] = False