mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 03:55:28 +00:00
b74b9aef33
Added a `cookies` property accessor to the `BaseClient` class, which retrieves cookies from the `httpx` AsyncClient object and returns a `simnet.client.cookies.Cookies` object (which is a custom implementation of the `httpx.Cookies` class). Additionally, the initialization function was refactored to better support using cookies. Now, if `account_id` is not passed in, it will be retrieved from the cookies.
18 lines
597 B
Python
18 lines
597 B
Python
import pytest
|
|
|
|
from simnet.client.base import BaseClient
|
|
from simnet.client.cookies import Cookies
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
class TestBaseClient:
|
|
@staticmethod
|
|
async def test_cookies():
|
|
async with BaseClient(cookies={"uid": "114514"}) as client:
|
|
assert isinstance(client.cookies, Cookies)
|
|
client.cookies = {"account_id": "114514"}
|
|
assert isinstance(client.cookies, Cookies)
|
|
assert client.cookies.get("account_id") == "114514"
|
|
client.cookies.set("stuid", "114514")
|
|
assert client.cookies.get("stuid") == "114514"
|