mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Small refactoring of telegram api server
This commit is contained in:
parent
0e35b6f55e
commit
a46cd6d001
6 changed files with 43 additions and 26 deletions
|
|
@ -1,11 +0,0 @@
|
|||
from aiogram.api.client.session.base import PRODUCTION
|
||||
|
||||
|
||||
class TestAPIServer:
|
||||
def test_method_url(self):
|
||||
method_url = PRODUCTION.api_url(token="TOKEN", method="apiMethod")
|
||||
assert method_url == "https://api.telegram.org/botTOKEN/apiMethod"
|
||||
|
||||
def test_file_url(self):
|
||||
file_url = PRODUCTION.file_url(token="TOKEN", path="path")
|
||||
assert file_url == "https://api.telegram.org/file/botTOKEN/path"
|
||||
|
|
@ -2,11 +2,11 @@ import datetime
|
|||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
from aiogram.api.client.session.base import BaseSession
|
||||
from aiogram.api.client.telegram import PRODUCTION, TelegramAPIServer
|
||||
from aiogram.api.methods import GetMe, Response
|
||||
from aiogram.utils.mixins import DataMixin
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
|
||||
class TestBaseSession(DataMixin):
|
||||
|
|
@ -17,6 +17,18 @@ class TestBaseSession(DataMixin):
|
|||
def teardown(self):
|
||||
BaseSession.__abstractmethods__ = self["__abstractmethods__"]
|
||||
|
||||
def test_init_api(self):
|
||||
session = BaseSession()
|
||||
assert session.api == PRODUCTION
|
||||
|
||||
def test_init_custom_api(self):
|
||||
api = TelegramAPIServer(
|
||||
base="http://example.com/{token}/{method}",
|
||||
file="http://example.com/{token}/file/{path{",
|
||||
)
|
||||
session = BaseSession(api=api)
|
||||
assert session.api == api
|
||||
|
||||
def test_sync_close(self):
|
||||
session = BaseSession()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue