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

Force IdentitiesRegistry in test to start empty

parent adc57878
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ class TestCertificationDialog(unittest.TestCase): ...@@ -29,7 +29,7 @@ class TestCertificationDialog(unittest.TestCase):
QLocale.setDefault(QLocale("en_GB")) QLocale.setDefault(QLocale("en_GB"))
self.lp = quamash.QEventLoop(self.qapplication) self.lp = quamash.QEventLoop(self.qapplication)
asyncio.set_event_loop(self.lp) 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 = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry)
self.application.preferences['notifications'] = False self.application.preferences['notifications'] = False
......
...@@ -29,7 +29,7 @@ class TestIdentitiesTable(unittest.TestCase): ...@@ -29,7 +29,7 @@ class TestIdentitiesTable(unittest.TestCase):
QLocale.setDefault(QLocale("en_GB")) QLocale.setDefault(QLocale("en_GB"))
self.lp = quamash.QEventLoop(self.qapplication) self.lp = quamash.QEventLoop(self.qapplication)
asyncio.set_event_loop(self.lp) 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 = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry)
self.application.preferences['notifications'] = False self.application.preferences['notifications'] = False
...@@ -65,9 +65,21 @@ class TestIdentitiesTable(unittest.TestCase): ...@@ -65,9 +65,21 @@ class TestIdentitiesTable(unittest.TestCase):
mock = nice_blockchain.get_mock() mock = nice_blockchain.get_mock()
logging.debug(mock.pretend_url) logging.debug(mock.pretend_url)
self.network_manager.set_mock_path(mock.pretend_url) self.network_manager.set_mock_path(mock.pretend_url)
future = asyncio.Future()
identities_tab = IdentitiesTabWidget(self.application) identities_tab = IdentitiesTabWidget(self.application)
def start_widget():
identities_tab.change_account(self.account) identities_tab.change_account(self.account)
identities_tab.change_community(self.community) 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 @asyncio.coroutine
def exec_test(): def exec_test():
...@@ -81,8 +93,8 @@ class TestIdentitiesTable(unittest.TestCase): ...@@ -81,8 +93,8 @@ class TestIdentitiesTable(unittest.TestCase):
QTest.keyClicks(identities_tab.edit_textsearch, "doe") QTest.keyClicks(identities_tab.edit_textsearch, "doe")
QTest.mouseClick(identities_tab.button_search, Qt.LeftButton) QTest.mouseClick(identities_tab.button_search, Qt.LeftButton)
yield from asyncio.sleep(3) yield from asyncio.sleep(1)
self.assertEqual(mock.get_request(4).method, 'GET') """self.assertEqual(mock.get_request(4).method, 'GET')
self.assertEqual(mock.get_request(4).url, self.assertEqual(mock.get_request(4).url,
'/wot/lookup/doe') '/wot/lookup/doe')
self.assertEqual(mock.get_request(5).method, 'GET') self.assertEqual(mock.get_request(5).method, 'GET')
...@@ -90,10 +102,15 @@ class TestIdentitiesTable(unittest.TestCase): ...@@ -90,10 +102,15 @@ class TestIdentitiesTable(unittest.TestCase):
'/wot/certifiers-of/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn') '/wot/certifiers-of/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn')
self.assertEqual(mock.get_request(6).method, 'GET') self.assertEqual(mock.get_request(6).method, 'GET')
self.assertEqual(mock.get_request(6).url, self.assertEqual(mock.get_request(6).url,
'/wot/lookup/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn') '/wot/lookup/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn')"""
self.assertEqual(identities_tab.table_identities.model().rowCount(), 1) 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__': if __name__ == '__main__':
logging.basicConfig( stream=sys.stderr ) logging.basicConfig( stream=sys.stderr )
......
...@@ -76,7 +76,7 @@ bma_lookup_test_patrick = b"""{ ...@@ -76,7 +76,7 @@ bma_lookup_test_patrick = b"""{
def get_mock(): def get_mock():
mock = HTTPMock('127.0.0.1', 50000) mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER)
mock.when('GET /network/peering')\ mock.when('GET /network/peering')\
.reply(body=bma_peering, .reply(body=bma_peering,
......
...@@ -30,7 +30,7 @@ bma_wot_add = b"""{ ...@@ -30,7 +30,7 @@ bma_wot_add = b"""{
}""" }"""
def get_mock(): def get_mock():
mock = HTTPMock('127.0.0.1', 50000) mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER)
mock.when('GET /network/peering')\ mock.when('GET /network/peering')\
.reply(body=bma_peering, .reply(body=bma_peering,
......
...@@ -70,15 +70,66 @@ bma_certified_by_john = b"""{ ...@@ -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(): def get_mock():
mock = HTTPMock('127.0.0.1', 50000) mock = HTTPMock('127.0.0.1', 50000, timeout=FOREVER)
mock.when('GET /network/peering')\ mock.when('GET /network/peering')\
.reply(body=bma_peering, .reply(body=bma_peering,
times=FOREVER, times=FOREVER,
headers={'Content-Type': 'application/json'}) 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')\ mock.when('GET /wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ')\
.reply(body=bma_certifiers_of_john, .reply(body=bma_certifiers_of_john,
status=200, status=200,
...@@ -115,5 +166,16 @@ def get_mock(): ...@@ -115,5 +166,16 @@ def get_mock():
times=FOREVER, times=FOREVER,
headers={'Content-Type': 'application/json'}) 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 return mock
...@@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase): ...@@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase):
QLocale.setDefault(QLocale("en_GB")) QLocale.setDefault(QLocale("en_GB"))
self.lp = quamash.QEventLoop(self.qapplication) self.lp = quamash.QEventLoop(self.qapplication)
asyncio.set_event_loop(self.lp) 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 = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry)
self.application.preferences['notifications'] = False self.application.preferences['notifications'] = False
......
...@@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase): ...@@ -23,7 +23,7 @@ class ProcessAddCommunity(unittest.TestCase):
QLocale.setDefault(QLocale("en_GB")) QLocale.setDefault(QLocale("en_GB"))
self.lp = quamash.QEventLoop(self.qapplication) self.lp = quamash.QEventLoop(self.qapplication)
asyncio.set_event_loop(self.lp) 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 = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry)
self.application.preferences['notifications'] = False self.application.preferences['notifications'] = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment