Skip to content

Commit fc74683

Browse files
committed
Fix linting.
1 parent 9f1c651 commit fc74683

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

libs/aries-basic-controller/aries_basic_controller/tests/test_aries_controller.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import logging
22
import pytest
3-
import pytest_asyncio
4-
from aiohttp import (
5-
web,
6-
ClientSession,
7-
)
83

94
from ..aries_webhook_server import AriesWebhookServer
105
from ..controllers.multitenant import MultitenancyController
@@ -25,26 +20,30 @@ class TestAriesAgentController():
2520
async def test_init_args_missing(self):
2621
with pytest.raises(TypeError) as te:
2722
AriesAgentController()
28-
assert "__init__() missing 1 required positional argument: 'admin_url'" \
29-
in str(te.value)
23+
assert "__init__() missing 1 required positional argument: \
24+
'admin_url'" in str(te.value)
3025

3126
@pytest.mark.asyncio
3227
async def test_init_args_multi_default(self):
3328
ac = AriesAgentController(admin_url=self.admin_url)
34-
assert ac.is_multitenant == False
29+
assert not ac.is_multitenant
3530

3631
@pytest.mark.asyncio
3732
async def test_init_args_multi_true(self):
38-
ac = AriesAgentController(admin_url=self.admin_url, is_multitenant=True)
39-
assert ac.is_multitenant == True
33+
ac = AriesAgentController(
34+
admin_url=self.admin_url,
35+
is_multitenant=True)
36+
assert ac.is_multitenant
4037
assert type(ac.multitenant) == MultitenancyController
4138
assert ac.multitenant.admin_url == self.admin_url
4239
assert ac.multitenant.client_session.headers == {}
4340
await ac.terminate()
4441

4542
@pytest.mark.asyncio
4643
async def test_init_webhook_server(self):
47-
ac = AriesAgentController(admin_url=self.admin_url, is_multitenant=True)
44+
ac = AriesAgentController(
45+
admin_url=self.admin_url,
46+
is_multitenant=True)
4847
ac.init_webhook_server(
4948
self.webhook_host,
5049
self.webhook_port,
@@ -54,23 +53,27 @@ async def test_init_webhook_server(self):
5453
assert ac.webhook_server.webhook_base == self.webhook_base
5554
assert ac.webhook_server.webhook_port == self.webhook_port
5655
assert ac.webhook_server.webhook_host == self.webhook_host
57-
assert ac.webhook_server.is_multitenant == True
56+
assert ac.webhook_server.is_multitenant
5857
await ac.terminate()
5958

6059
@pytest.mark.asyncio
6160
async def test_listen_webhooks_error(self, caplog):
6261
caplog.set_level(logging.WARNING)
63-
ac = AriesAgentController(admin_url=self.admin_url, is_multitenant=True)
62+
ac = AriesAgentController(
63+
admin_url=self.admin_url,
64+
is_multitenant=True)
6465
with pytest.raises(AttributeError) as ae:
6566
await ac.listen_webhooks()
6667
assert "Webhook server not initialised." in str(ae.value)
6768
assert "Webhook server not initialised." in caplog.text
6869
await ac.terminate()
6970

7071
@pytest.mark.asyncio
71-
async def test_init_webhook_server(self, caplog):
72+
async def test_init_webhook_server_terminate(self, caplog):
7273
caplog.set_level(logging.INFO)
73-
ac = AriesAgentController(admin_url=self.admin_url, is_multitenant=True)
74+
ac = AriesAgentController(
75+
admin_url=self.admin_url,
76+
is_multitenant=True)
7477
ac.init_webhook_server(
7578
self.webhook_host,
7679
self.webhook_port,
@@ -80,5 +83,5 @@ async def test_init_webhook_server(self, caplog):
8083
assert "Webhook server started." in caplog.text
8184
res = await ac.webhook_server.terminate()
8285
assert "Webhook server terminated." in caplog.text
83-
assert res == None
86+
assert res is None
8487
await ac.terminate()

libs/aries-basic-controller/aries_basic_controller/tests/test_aries_controller_base.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import pytest
3-
import pytest_asyncio
43
from aiohttp import (
54
ClientSession,
65
)
@@ -29,17 +28,17 @@ class TestAriesAgentControllerBase():
2928
@pytest.mark.asyncio
3029
async def test_init_args_missing(self):
3130
with pytest.raises(TypeError) as te:
32-
ac = AriesAgentControllerBase()
33-
assert "__init__() missing 1 required positional argument: 'admin_url'" \
34-
in str(te.value)
35-
31+
AriesAgentControllerBase()
32+
assert "__init__() missing 1 required positional \
33+
argument: 'admin_url'" in str(te.value)
34+
3635
@pytest.mark.asyncio
3736
async def test_default_args(self):
3837
ac = AriesAgentControllerBase(admin_url="0.0.0.0")
3938
assert ac.admin_url == "0.0.0.0"
40-
assert ac.api_key == None
41-
assert ac.webhook_site == None
42-
assert ac.connections_controller == None
39+
assert ac.api_key is None
40+
assert ac.webhook_site is None
41+
assert ac.connections_controller is None
4342
assert type(ac.client_session) == ClientSession
4443
assert type(ac.connections) == ConnectionsController
4544
assert type(ac.messaging) == MessagingController
@@ -87,17 +86,19 @@ async def test_update_api_key(self):
8786
assert ac.client_session.headers == new_exp_headers
8887

8988
await ac.terminate()
90-
89+
9190
@pytest.mark.asyncio
9291
async def test_remove_api_key(self):
9392
api_key = "123456789"
93+
9494
ac = AriesAgentControllerBase(admin_url="", api_key=api_key)
95-
exp_headers = {"X-API-Key": api_key}
9695
ac.remove_api_key()
96+
9797
assert ac.headers == {}
9898
assert ac.client_session.headers == {}
99+
99100
await ac.terminate()
100-
101+
101102
# TODO create mock for pubsub listening webhooks
102103
# Maybe this makes more sense in aries_controller
103104
@pytest.mark.asyncio
@@ -129,7 +130,7 @@ async def test_terminate(self, caplog):
129130
ac = AriesAgentControllerBase(admin_url="0.0.0.0")
130131
await ac.terminate()
131132
assert "Client Session closed." in caplog.text
132-
assert ac.client_session.closed == True
133+
assert ac.client_session.closed
133134
with pytest.raises(AttributeError):
134-
assert ac.webhook_server == None
135+
assert ac.webhook_server is None
135136
await ac.terminate()

libs/aries-basic-controller/aries_basic_controller/tests/test_aries_tenant_controller.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import logging
22
import re
33
import pytest
4-
import pytest_asyncio
5-
from aiohttp import (
6-
web,
7-
ClientSession,
8-
)
9-
10-
from ..aries_webhook_server import AriesWebhookServer
11-
from ..controllers.multitenant import MultitenancyController
124

135
from ..aries_tenant_controller import AriesTenantController
146

@@ -27,16 +19,18 @@ class TestAriesTenantController():
2719
@pytest.mark.asyncio
2820
async def test_init_args_missing_wallet_id(self):
2921
with pytest.raises(
30-
TypeError,
22+
TypeError,
3123
match=re.escape("__init__ missing required wallet_id (str)")):
3224
AriesTenantController(admin_url=self.admin_url)
3325

3426
@pytest.mark.asyncio
3527
async def test_init_args_missing_tenant_jwt(self):
3628
with pytest.raises(
37-
TypeError,
29+
TypeError,
3830
match=re.escape("__init__ missing required tenant_jwt (str)")):
39-
AriesTenantController(admin_url=self.admin_url, wallet_id=self.wallet_id)
31+
AriesTenantController(
32+
admin_url=self.admin_url,
33+
wallet_id=self.wallet_id)
4034

4135
@pytest.mark.asyncio
4236
async def test_init_webhook_server(self):
@@ -46,7 +40,8 @@ async def test_init_webhook_server(self):
4640
tenant_jwt=self.tenant_jwt)
4741
with pytest.raises(
4842
NotImplementedError,
49-
match=("Please, use an AriesAgentController to start a webhook server\n"
43+
match=(
44+
"Please, use an AriesAgentController to start a webhook server\n"
5045
"Webhook server fct is disallowed for tenant controllers.")):
5146
ac.init_webhook_server()
5247
await ac.terminate()
@@ -59,7 +54,8 @@ async def test_listen_webhooks(self):
5954
tenant_jwt=self.tenant_jwt)
6055
with pytest.raises(
6156
NotImplementedError,
62-
match=("Please, use an AriesAgentController to start a webhook server\n"
57+
match=(
58+
"Please, use an AriesAgentController to start a webhook server\n"
6359
"Webhook server fct is disallowed for tenant controllers.")):
6460
ac.listen_webhooks()
6561
await ac.terminate()
@@ -92,7 +88,9 @@ async def test_update_tenant_jwt(self):
9288
wallet_id=self.wallet_id,
9389
tenant_jwt=self.tenant_jwt)
9490
assert ac.tenant_jwt != new_tenant_jwt
95-
ac.update_tenant_jwt(wallet_id=self.wallet_id, tenant_jwt=new_tenant_jwt)
91+
ac.update_tenant_jwt(
92+
wallet_id=self.wallet_id,
93+
tenant_jwt=new_tenant_jwt)
9694
assert ac.tenant_jwt == new_tenant_jwt
9795
with pytest.raises(
9896
AssertionError,
@@ -113,7 +111,7 @@ async def test_remove_tenant_jwt(self):
113111
ac.remove_tenant_jwt()
114112
assert not ac.tenant_jwt
115113
assert 'Authorization' not in ac.headers
116-
assert 'Authorization' not in ac.client_session.headers
117-
assert 'content-type' not in ac.client_session.headers
118-
assert 'content-type' not in ac.headers
114+
assert 'Authorization' not in ac.client_session.headers
115+
assert 'content-type' not in ac.client_session.headers
116+
assert 'content-type' not in ac.headers
119117
await ac.terminate()

libs/aries-basic-controller/aries_basic_controller/tests/test_aries_webhook_server.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import logging
22
import re
33
import pytest
4-
import pytest_asyncio
5-
from aiohttp import (
6-
web,
7-
ClientSession,
8-
)
94

105
from ..aries_webhook_server import AriesWebhookServer
116

@@ -21,7 +16,7 @@ class TestAriesWebhookServer():
2116
@pytest.mark.asyncio
2217
async def test_init_args_missing_webhook_host(self):
2318
with pytest.raises(
24-
TypeError,
19+
TypeError,
2520
match=re.escape(
2621
"__init__() missing 1 required positional argument: 'webhook_host'"
2722
)):
@@ -52,7 +47,7 @@ async def test_listen_webhooks(self, caplog):
5247

5348
# TODO create mocks for pubsub webhook handling
5449
# Not quite sure how to do this best
55-
50+
5651
@pytest.mark.asyncio
5752
async def test_terminate(self, caplog):
5853
caplog.set_level(logging.INFO)

0 commit comments

Comments
 (0)