diff --git a/README.rst b/README.rst index 6adc76eba90a075c0eb6603b86709699aef6a5bd..8515055620c9aa4899623e4db3f2b13ed65947aa 100644 --- a/README.rst +++ b/README.rst @@ -16,28 +16,38 @@ Features Requirements ------------ -* Python >= 3.5 -* `aiohttp >= 0.19 <https://pypi.python.org/pypi/aiohttp>`_ -* `pylibscrypt <https://pypi.python.org/pypi/pylibscrypt>`_ -* `libnacl <https://pypi.python.org/pypi/libnacl>`_ -* `base58 <https://pypi.python.org/pypi/base58>`_ +* Python >= 3.5.2 +* `aiohttp >= 0.19 <https://pypi.org/pypi/aiohttp>`_ +* `pylibscrypt <https://pypi.org/pypi/pylibscrypt>`_ +* `libnacl <https://pypi.org/pypi/libnacl>`_ +* `base58 <https://pypi.org/pypi/base58>`_ +* `attr <https://pypi.org/project/attr/>`_ Installation ------------ -You can install duniter-python-api and all its dependencies via the following pip install: +You can install duniter-python-api and all its dependencies via the following pip install:: -:code:`pip3 install duniterpy` + pip3 install duniterpy Please take a look at the document `HTTP API <https://git.duniter.org/nodes/typescript/duniter/blob/master/doc/HTTP_API.md>`_ to learn about the API. Development ----------- -* Create a python environment with pyenv +* Create a python environment with `pyenv <https://github.com/pyenv/pyenv>`_ :: + + curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash` + * Add PYTHONPATH env var to your shell containing the path to this repository -* Take a look at examples -* Run examples from parent folder :code:`python examples/request_data.py` +* Run unit tests with :: + + python -m unittest + +* Take a look at examples folder +* Run examples from parent folder :: + + python examples/request_data.py Documentation ------------- diff --git a/duniterpy/documents/peer.py b/duniterpy/documents/peer.py index cf74b3ca5c2998a7c3c81c6a35c0f6e11564ea1a..a638d53655f6fd6df78a0697fcafff3c9f8e4dbf 100644 --- a/duniterpy/documents/peer.py +++ b/duniterpy/documents/peer.py @@ -1,4 +1,5 @@ import re +import aiohttp from typing import Generator from ..api.bma import ConnectionHandler @@ -184,20 +185,20 @@ class BMAEndpoint(Endpoint): IPv6=(" {0}".format(self.ipv6) if self.ipv6 else ""), PORT=(" {0}".format(self.port) if self.port else "")) - def conn_handler(self, session=None, proxy=None): + def conn_handler(self, session: aiohttp.ClientSession = None, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param aiohttp.ClientSession session: AIOHTTP client session instance :param str proxy: Proxy url - :rtype: Generator[ConnectionHandler, None, None] + :rtype: ConnectionHandler """ if self.server: - yield ConnectionHandler("http", "ws", self.server, self.port, "", proxy, session) + return ConnectionHandler("http", "ws", self.server, self.port, "", proxy, session) elif self.ipv6: - yield ConnectionHandler("http", "ws", "[{0}]".format(self.ipv6), self.port, "", proxy, session) - else: - yield ConnectionHandler("http", "ws", self.ipv4, self.port, "", proxy, session) + return ConnectionHandler("http", "ws", "[{0}]".format(self.ipv6), self.port, "", proxy, session) + + return ConnectionHandler("http", "ws", self.ipv4, self.port, "", proxy, session) def __str__(self): return self.inline() @@ -242,20 +243,20 @@ class SecuredBMAEndpoint(BMAEndpoint): inlined = [str(info) for info in (self.server, self.ipv4, self.ipv6, self.port, self.path) if info] return SecuredBMAEndpoint.API + " " + " ".join(inlined) - def conn_handler(self, session=None, proxy=None): + def conn_handler(self, session: aiohttp.ClientSession = None, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param aiohttp.ClientSession session: AIOHTTP client session instance :param str proxy: Proxy url - :rtype: Generator[ConnectionHandler, None, None] + :rtype: ConnectionHandler """ if self.server: - yield ConnectionHandler("https", "wss", self.server, self.port, self.path, proxy, session) + return ConnectionHandler("https", "wss", self.server, self.port, self.path, proxy, session) elif self.ipv6: - yield ConnectionHandler("https", "wss", "[{0}]".format(self.ipv6), self.port, self.path, proxy, session) - else: - yield ConnectionHandler("https", "wss", self.ipv4, self.port, self.path, proxy, session) + return ConnectionHandler("https", "wss", "[{0}]".format(self.ipv6), self.port, self.path, proxy, session) + + return ConnectionHandler("https", "wss", self.ipv4, self.port, self.path, proxy, session) class WS2PEndpoint(Endpoint): @@ -289,14 +290,15 @@ class WS2PEndpoint(Endpoint): inlined = [str(info) for info in (self.ws2pid, self.server, self.port, self.path) if info] return WS2PEndpoint.API + " " + " ".join(inlined) - def conn_handler(self, session=None, proxy=None): + def conn_handler(self, session: aiohttp.ClientSession = None, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param aiohttp.ClientSession session: AIOHTTP client session instance + :param str proxy: Proxy url :rtype: ConnectionHandler """ - yield ConnectionHandler("https", "wss", self.server, self.port, self.path, proxy, session) + return ConnectionHandler("https", "wss", self.server, self.port, self.path, proxy, session) def __str__(self): return self.inline() @@ -335,14 +337,15 @@ class ESUserEndpoint(Endpoint): inlined = [str(info) for info in (self.server, self.port) if info] return ESUserEndpoint.API + " " + " ".join(inlined) - def conn_handler(self, session=None, proxy=None): + def conn_handler(self, session: aiohttp.ClientSession = None, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param aiohttp.ClientSession session: AIOHTTP client session instance + :param str proxy: Proxy url :rtype: ConnectionHandler """ - yield ConnectionHandler("https", "wss", self.server, self.port, "", proxy, session) + return ConnectionHandler("https", "wss", self.server, self.port, "", proxy, session) def __str__(self): return self.inline() @@ -380,14 +383,15 @@ class ESSubscribtionEndpoint(Endpoint): inlined = [str(info) for info in (self.server, self.port) if info] return ESSubscribtionEndpoint.API + " " + " ".join(inlined) - def conn_handler(self, session=None, proxy=None): + def conn_handler(self, session: aiohttp.ClientSession = None, proxy: str = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint :param aiohttp.ClientSession session: AIOHTTP client session instance + :param str proxy: Proxy url :rtype: ConnectionHandler """ - yield ConnectionHandler("https", "wss", self.server, self.port, "", proxy, session) + return ConnectionHandler("https", "wss", self.server, self.port, "", proxy, session) def __str__(self): return self.inline() @@ -402,8 +406,7 @@ class ESSubscribtionEndpoint(Endpoint): return hash((ESSubscribtionEndpoint.API, self.server, self.port)) - -MANAGED_API={ +MANAGED_API = { BMAEndpoint.API: BMAEndpoint, SecuredBMAEndpoint.API: SecuredBMAEndpoint, WS2PEndpoint.API: WS2PEndpoint, diff --git a/examples/create_and_publish_identity.py b/examples/create_and_publish_identity.py index 559fd83dd9bd8942e19b12b6427b04726015405b..b4fb846d6cafff1293c07c70e1bd278cd034a44f 100644 --- a/examples/create_and_publish_identity.py +++ b/examples/create_and_publish_identity.py @@ -63,7 +63,7 @@ async def main(): """ # connection handler from BMA endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) diff --git a/examples/request_data.py b/examples/request_data.py index 1680352c8bdfb746654afa53b483f0a24d29d903..87efed5f6b2b0dd12d99758e45c9e2bc9503add0 100644 --- a/examples/request_data.py +++ b/examples/request_data.py @@ -22,7 +22,7 @@ async def main(): Main code """ # connection handler from BMA endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # Get the node summary infos response = await bma.node.summary(connection) diff --git a/examples/save_revoke_document.py b/examples/save_revoke_document.py index 3664de56a99c987dbd35010eb5d6cf4740c23de5..1209db35237b233c67a004222f358d6b0ed816de 100644 --- a/examples/save_revoke_document.py +++ b/examples/save_revoke_document.py @@ -113,7 +113,7 @@ async def main(): exit(0) # connection handler from BMAS endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # capture current block to get currency name current_block = await bma.blockchain.current(connection) diff --git a/examples/send_certification.py b/examples/send_certification.py index b7318cbd479d17b38044acc67c84ca43a4a5c35d..d31fb76590e4790754c71049d6b2bef2eb5f0d1e 100644 --- a/examples/send_certification.py +++ b/examples/send_certification.py @@ -92,7 +92,7 @@ async def main(): Main code """ # connection handler from BMA endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") diff --git a/examples/send_membership.py b/examples/send_membership.py index b1d22ea8ac11c2a182fa542731fb9f952d4d3fa5..790aa6a36ca6e7f8608d156626adbce0f01b83f7 100644 --- a/examples/send_membership.py +++ b/examples/send_membership.py @@ -97,7 +97,7 @@ async def main(): Main code """ # connection handler from BMA endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) diff --git a/examples/send_transaction.py b/examples/send_transaction.py index a78f3a3c220342c978a5a9499ed4e7cfc0d5e657..efd75736cbc06bbb227e701ccf92a7068282f6bf 100644 --- a/examples/send_transaction.py +++ b/examples/send_transaction.py @@ -95,7 +95,7 @@ async def main(): Main code """ # connection handler from BMA endpoint - connection = next(SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) + connection = SecuredBMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") diff --git a/requirements.txt b/requirements.txt index 3956c62a8a937ac16fbefd5c2f9271978ce2f471..38c71ad378007086211cfe5d8f4fde06629f5fb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -aiohttp -pylibscrypt -libnacl -base58 -jsonschema -pypeg2 +aiohttp >= 3.3.2 +pylibscrypt >= 1.7.1 +libnacl >= 1.6.1 +base58 >= 1.0.0 +jsonschema >= 2.6.0 +pypeg2 >= 2.15.2 +attr >= 0.3.1 diff --git a/tests/api/bma/test_blockchain.py b/tests/api/bma/test_blockchain.py index a8ea1b954ebdd02a9acdb2caf8713c55e060ac8d..a4c3b41d9ed1ac66b195466e9006ce08b2ac46cd 100644 --- a/tests/api/bma/test_blockchain.py +++ b/tests/api/bma/test_blockchain.py @@ -44,7 +44,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/parameters', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await parameters(connection) self.loop.run_until_complete(go()) @@ -113,7 +113,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/block/100', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await block(connection, 100) self.loop.run_until_complete(go()) @@ -127,7 +127,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/current', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await current(connection) self.loop.run_until_complete(go()) @@ -188,7 +188,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/hardship/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await hardship(connection, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU") self.loop.run_until_complete(go()) @@ -228,7 +228,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/memberships/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await memberships(connection, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU") self.loop.run_until_complete(go()) @@ -250,7 +250,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/newcomers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await newcomers(connection) self.loop.run_until_complete(go()) @@ -272,7 +272,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/certs', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await certifications(connection) self.loop.run_until_complete(go()) @@ -294,7 +294,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/joiners', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await joiners(connection) self.loop.run_until_complete(go()) @@ -316,7 +316,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/actives', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await actives(connection) self.loop.run_until_complete(go()) @@ -338,7 +338,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/leavers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await leavers(connection) self.loop.run_until_complete(go()) @@ -461,7 +461,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/ud', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await ud(connection) self.loop.run_until_complete(go()) @@ -483,7 +483,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/blockchain/with/tx', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await tx(connection) self.loop.run_until_complete(go()) diff --git a/tests/api/bma/test_network.py b/tests/api/bma/test_network.py index bf7b68d46879104f236d681192641ae04a4eb39c..a4600ab7e087699b123428fe7763797f4c7f6697 100644 --- a/tests/api/bma/test_network.py +++ b/tests/api/bma/test_network.py @@ -33,7 +33,7 @@ class TestBMANetwork(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/network/peering', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await network.peering(connection) self.loop.run_until_complete(go()) @@ -73,7 +73,7 @@ class TestBMANetwork(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/network/peering/peers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await network.peers(connection) self.loop.run_until_complete(go()) diff --git a/tests/api/bma/test_tx.py b/tests/api/bma/test_tx.py index 6e8d72ad268b9ceef7da905427fa18590ffc54f2..3e8d78fb78f1fdd93510151caaedcff03c6bf757 100644 --- a/tests/api/bma/test_tx.py +++ b/tests/api/bma/test_tx.py @@ -129,7 +129,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/tx/history/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await history(connection, 'pubkey') self.loop.run_until_complete(go()) @@ -143,7 +143,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/tx/history/pubkey/blocks/0/100', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await blocks(connection, 'pubkey', 0, 100) self.loop.run_until_complete(go()) @@ -182,7 +182,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/tx/sources/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await sources(connection, 'pubkey') - self.loop.run_until_complete(go()) \ No newline at end of file + self.loop.run_until_complete(go()) diff --git a/tests/api/bma/test_wot.py b/tests/api/bma/test_wot.py index c44fbed655bd1e357f4e42ec01478455bb91b3b7..061890e925ebbc12f92f381c482bac7b18b84ed4 100644 --- a/tests/api/bma/test_wot.py +++ b/tests/api/bma/test_wot.py @@ -168,7 +168,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/wot/lookup/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await lookup(connection, 'pubkey') self.loop.run_until_complete(go()) @@ -192,7 +192,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/wot/members', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await members(connection) self.loop.run_until_complete(go()) @@ -246,7 +246,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/wot/certifiers-of/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await certifiers_of(connection, 'pubkey') self.loop.run_until_complete(go()) @@ -278,7 +278,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/wot/certifiers-of/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await certifiers_of(connection, 'pubkey') self.loop.run_until_complete(go()) @@ -292,7 +292,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/wot/certified-by/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await certified_by(connection, 'pubkey') self.loop.run_until_complete(go()) diff --git a/tests/api/bma/test_ws2p.py b/tests/api/bma/test_ws2p.py index 3b911b5b9def764046d71159a631b42340eb0b09..1e4c9e817ebb3fa9de26d57ec58a0b49ab32d5fa 100644 --- a/tests/api/bma/test_ws2p.py +++ b/tests/api/bma/test_ws2p.py @@ -48,7 +48,7 @@ class Test_WS2P_Heads(WebFunctionalSetupMixin, unittest.TestCase): _, port, url = await self.create_server('GET', '/network/ws2p/heads', handler) with self.assertRaises(jsonschema.ValidationError): async with aiohttp.ClientSession() as session: - connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) + connection = BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session) await heads(connection) self.loop.run_until_complete(go()) diff --git a/tests/api/test_bma.py b/tests/api/test_bma.py index 9fa00d04f06fcd577488cf372d1186c8a12dd688..f6791bc7c0c55cfe251e1e2f678245fdd4e0f0b2 100644 --- a/tests/api/test_bma.py +++ b/tests/api/test_bma.py @@ -7,17 +7,17 @@ class Test_BMA_API(unittest.TestCase): def test_reverse_url_complete(self): endpoint = BMAEndpoint("test.com", "124.2.2.1", "2001:0db8:0000:85a3:0000:0000:ac1f:8001 ", 9092) - api = API(next(endpoint.conn_handler()), "any") + api = API(endpoint.conn_handler(), "any") self.assertEqual(api.reverse_url("http", "/test/url"), "http://test.com:9092/any/test/url") def test_reverse_url_only_ipv4(self): endpoint = BMAEndpoint(None, "124.2.2.1", None, 9092) - api = API(next(endpoint.conn_handler()), "any") + api = API(endpoint.conn_handler(), "any") self.assertEqual(api.reverse_url("http", "/test/url"), "http://124.2.2.1:9092/any/test/url") def test_reverse_url_only_ipv6(self): endpoint = BMAEndpoint(None, None, "2001:0db8:0000:85a3:0000:0000:ac1f:8001", 9092) - api = API(next(endpoint.conn_handler()), "any") + api = API(endpoint.conn_handler(), "any") self.assertEqual(api.reverse_url("http", "/test/url"), "http://[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:9092/any/test/url") def test_parse_error(self):