Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed Sep 25, 2024
1 parent 79c53e0 commit 220bc45
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cozepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .auth import ApplicationOAuth, Auth, TokenAuth,JWTAuth
from .auth import ApplicationOAuth, Auth, TokenAuth, JWTAuth
from .config import COZE_COM_BASE_URL, COZE_CN_BASE_URL
from .coze import Coze
from .model import (
Expand Down
6 changes: 1 addition & 5 deletions cozepy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ class JWTAuth(Auth):
The JWT auth flow.
"""

def __init__(self, client_id: str,
private_key: str,
kid: str,
ttl: int = 7200,
base_url: str = COZE_COM_BASE_URL):
def __init__(self, client_id: str, private_key: str, kid: str, ttl: int = 7200, base_url: str = COZE_COM_BASE_URL):
assert isinstance(client_id, str)
assert isinstance(private_key, str)
assert isinstance(kid, str)
Expand Down
16 changes: 8 additions & 8 deletions cozepy/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def __init__(self, auth: "Auth" = None):
self._auth = auth

def request(
self,
method: str,
url: str,
model: Union[Type[T], List[Type[T]]],
params: dict = None,
headers: dict = None,
body: dict = None,
stream: bool = False,
self,
method: str,
url: str,
model: Union[Type[T], List[Type[T]]],
params: dict = None,
headers: dict = None,
body: dict = None,
stream: bool = False,
) -> Union[T, List[T], Iterator[bytes]]:
"""
Send a request to the server.
Expand Down
8 changes: 2 additions & 6 deletions tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
COZE_JWT_AUTH_PRIVATE_KEY = os.getenv("COZE_JWT_AUTH_PRIVATE_KEY").strip()
COZE_JWT_AUTH_KEY_ID = os.getenv("COZE_JWT_AUTH_KEY_ID").strip()

COZE_TOKEN = os.getenv('COZE_TOKEN').strip()
COZE_TOKEN = os.getenv("COZE_TOKEN").strip()

app_oauth = ApplicationOAuth(
COZE_JWT_AUTH_CLIENT_ID,
Expand All @@ -16,9 +16,5 @@
fixed_token_auth = TokenAuth(COZE_TOKEN)

jwt_auth = JWTAuth(
COZE_JWT_AUTH_CLIENT_ID,
COZE_JWT_AUTH_PRIVATE_KEY,
COZE_JWT_AUTH_KEY_ID,
30,
base_url=COZE_CN_BASE_URL
COZE_JWT_AUTH_CLIENT_ID, COZE_JWT_AUTH_PRIVATE_KEY, COZE_JWT_AUTH_KEY_ID, 30, base_url=COZE_CN_BASE_URL
)
2 changes: 1 addition & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def test_jwt_app_oauth():


def test_jwt_auth():
assert jwt_auth.token != ''
assert jwt_auth.token != ""
4 changes: 2 additions & 2 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_bot_v1_list(self):
# fixed token
Coze(auth=fixed_token_auth, base_url=COZE_CN_BASE_URL),
# jwt auth
Coze(auth=jwt_auth, base_url=COZE_CN_BASE_URL)
Coze(auth=jwt_auth, base_url=COZE_CN_BASE_URL),
]
for cli in cli_list:
res = cli.bot.v1.list(space_id=space_id, page_size=2)
Expand All @@ -28,7 +28,7 @@ def test_bot_v1_get_online_info(self):
# fixed token
Coze(auth=fixed_token_auth, base_url=COZE_CN_BASE_URL),
# jwt auth
Coze(auth=jwt_auth, base_url=COZE_CN_BASE_URL)
Coze(auth=jwt_auth, base_url=COZE_CN_BASE_URL),
]
for cli in cli_list:
bot = cli.bot.v1.get_online_info(bot_id=bot_id)
Expand Down

0 comments on commit 220bc45

Please sign in to comment.