Skip to content

Commit bf1c991

Browse files
committed
Address code review feedback
* minor tweaks * bump python version to min. 3.7.3 so dataclasses is in the standard library * TODO check in notebooks/rewirte notebooks
1 parent 6caa686 commit bf1c991

File tree

5 files changed

+92
-54
lines changed

5 files changed

+92
-54
lines changed

libs/aries-basic-controller/aries_basic_controller/aries_controller_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class AriesAgentControllerBase(ABC):
3636
admin_url : str
3737
The URL for the Admin API
3838
api_key : str
39-
The API key (default is None)
39+
The API key
4040
"""
4141

4242
admin_url: str
43-
api_key: str = None
43+
api_key: str
4444

4545
def __post_init__(self):
4646
"""Constructs additional attributes and logic
@@ -54,7 +54,7 @@ def __post_init__(self):
5454
# Construct headers for Client Session and the session itself
5555
self.headers = {}
5656

57-
if self.api_key:
57+
if self.api_key not in [None, ""]:
5858
self.headers.update({"X-API-Key": self.api_key})
5959

6060
self.client_session: ClientSession = ClientSession(

libs/aries-basic-controller/aries_basic_controller/aries_tenant_controller.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class AriesTenantController(AriesAgentControllerBase):
1313
"""The Aries Agent Controller class
1414
15-
This class allows you to interact with Aries by exposing the aca-py API.
15+
This class allows you to interact with Aries by exposing the aca-py API.
1616
1717
Attributes:
1818
----------
@@ -55,6 +55,7 @@ def add_listener(self, listener):
5555
Overrides parent method and uses the tenant's wallet ID to
5656
listen for that wallet's webhooks under the url defined
5757
by the wallet ID.
58+
5859
Args:
5960
----
6061
listener : dict
@@ -64,10 +65,9 @@ def add_listener(self, listener):
6465
try:
6566
pub_topic_path_base = listener['topic']
6667
pub_topic_path = f"{self.wallet_id}.{pub_topic_path_base}"
67-
print("Subscribing too: " + pub_topic_path)
6868
pub.subscribe(listener["handler"], pub_topic_path)
6969
logger.debug("Lister added for topic : ", pub_topic_path)
70-
except self.wallet_id is "":
70+
except self.wallet_id == "":
7171
logger.error(
7272
"Cannot add listener for empty wallet_id.")
7373
except Exception as exc:
@@ -83,7 +83,10 @@ def update_wallet_id(self, wallet_id: str):
8383
wallet_id : str
8484
The tenant wallet identifier
8585
"""
86-
self.wallet_id = wallet_id
86+
try:
87+
self.wallet_id = wallet_id
88+
except wallet_id == "":
89+
raise Exception("wallet_id must not be empty")
8790

8891
def update_tenant_jwt(self, tenant_jwt: str, wallet_id: str):
8992
"""Update the tenant JW token attribute and the header
@@ -102,6 +105,8 @@ def update_tenant_jwt(self, tenant_jwt: str, wallet_id: str):
102105
{'Authorization': 'Bearer ' + tenant_jwt,
103106
'content-type': "application/json"})
104107
self.client_session.headers.update(self.headers)
108+
except tenant_jwt == "":
109+
raise Exception("tenant_jwt must not be empty")
105110
except Exception as exc:
106111
logger.warning(
107112
(f"Updating tenant JW token"

libs/aries-basic-controller/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ termcolor
88
pillow
99
qrcode
1010
beautifulsoup4
11+
pytest~=6.2.3

libs/aries-basic-controller/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def parse_requirements(filename):
2222
if __name__ == "__main__":
2323
setup(
2424
name=PACKAGE_NAME,
25-
version="0.2",
25+
version="0.4",
2626
author="Will Abramson",
2727
description="A simple python package for controlling an aries agent through the admin-api interface",
2828
long_description=long_description,
@@ -32,7 +32,7 @@ def parse_requirements(filename):
3232
include_package_data=True,
3333
package_data={"aries_basic_controller": ["requirements.txt"]},
3434
install_requires=parse_requirements("requirements.txt"),
35-
python_requires=">=3.6.3",
35+
python_requires=">=3.7.3",
3636
classifiers=[
3737
"Programming Language :: Python :: 3",
3838
"License :: OSI Approved :: Apache Software License",

0 commit comments

Comments
 (0)