Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/saic_ismart_client_ng/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def __init__(
self.__api_client = SaicApiClient(configuration, listener=listener)
self.__token_expiration: datetime.datetime | None = None

async def close(self) -> None:
await self.__api_client.close()

async def login(self) -> LoginResp:
headers = {
"Content-Type": "application/x-www-form-urlencoded",
Expand Down
3 changes: 3 additions & 0 deletions src/saic_ismart_client_ng/net/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def __init__(
async def send(self, request: Request) -> Response:
return await self.__client.send(request)

async def close(self) -> None:
await self.__client.aclose()

@property
def user_token(self) -> str:
return self.__user_token
Expand Down
13 changes: 13 additions & 0 deletions tests/test_close.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

Check failure on line 1 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (I002)

tests/test_close.py:1:1: I002 Missing required import: `from __future__ import annotations`

from saic_ismart_client_ng import SaicApi
from saic_ismart_client_ng.model import SaicApiConfiguration


class TestClose(unittest.IsolatedAsyncioTestCase):
async def test_close_is_idempotent(self) -> None:
api = SaicApi(
SaicApiConfiguration(username="user", password="pass"),

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"

Check failure on line 10 in tests/test_close.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (S106)

tests/test_close.py:10:51: S106 Possible hardcoded password assigned to argument: "password"
)
await api.close()
await api.close()
Loading