mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
refactor(props):
simplify some descriptors with tests for them, remove silly "nocovers"
This commit is contained in:
parent
2c1de9cdbc
commit
2adc19724d
2 changed files with 34 additions and 18 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import json
|
||||
from typing import AsyncContextManager, AsyncGenerator
|
||||
|
||||
import pytest
|
||||
|
|
@ -35,6 +36,26 @@ class TestBaseSession:
|
|||
session = CustomSession()
|
||||
assert session.api == PRODUCTION
|
||||
|
||||
def test_default_props(self):
|
||||
session = CustomSession()
|
||||
assert session.api == PRODUCTION
|
||||
assert session.json_loads == json.loads
|
||||
assert session.json_dumps == json.dumps
|
||||
|
||||
def custom_loads(*_):
|
||||
return json.loads
|
||||
|
||||
def custom_dumps(*_):
|
||||
return json.dumps
|
||||
|
||||
session.json_dumps = custom_dumps
|
||||
assert session.json_dumps == custom_dumps == session._json_dumps
|
||||
session.json_loads = custom_loads
|
||||
assert session.json_loads == custom_loads == session._json_loads
|
||||
|
||||
different_session = CustomSession()
|
||||
assert all(not hasattr(different_session, attr) for attr in ("_json_loads", "_json_dumps", "_api"))
|
||||
|
||||
def test_init_custom_api(self):
|
||||
api = TelegramAPIServer(
|
||||
base="http://example.com/{token}/{method}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue