mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Rework session DI and files path wrapper
This commit is contained in:
parent
1357a7a91b
commit
2620a6547c
9 changed files with 98 additions and 40 deletions
|
|
@ -1,4 +1,11 @@
|
|||
from aiogram.client.telegram import PRODUCTION, TelegramAPIServer
|
||||
from pathlib import Path
|
||||
|
||||
from aiogram.client.telegram import (
|
||||
PRODUCTION,
|
||||
BareFilesPathWrapper,
|
||||
SimpleFilesPathWrapper,
|
||||
TelegramAPIServer,
|
||||
)
|
||||
|
||||
|
||||
class TestAPIServer:
|
||||
|
|
@ -19,3 +26,27 @@ class TestAPIServer:
|
|||
assert method_url == "http://localhost:8081/bot42:TEST/apiMethod"
|
||||
assert file_url == "http://localhost:8081/file/bot42:TEST/path"
|
||||
assert local_server.is_local
|
||||
|
||||
|
||||
class TestBareFilesPathWrapper:
|
||||
def test_to_local(self):
|
||||
wrapper = BareFilesPathWrapper()
|
||||
assert wrapper.to_local("/path/to/file.dat") == "/path/to/file.dat"
|
||||
|
||||
def test_to_server(self):
|
||||
wrapper = BareFilesPathWrapper()
|
||||
assert wrapper.to_server("/path/to/file.dat") == "/path/to/file.dat"
|
||||
|
||||
|
||||
class TestSimpleFilesPathWrapper:
|
||||
def test_to_local(self):
|
||||
wrapper = SimpleFilesPathWrapper(Path("/etc/telegram-bot-api/data"), Path("/opt/app/data"))
|
||||
assert wrapper.to_local("/etc/telegram-bot-api/data/documents/file.dat") == Path(
|
||||
"/opt/app/data/documents/file.dat"
|
||||
)
|
||||
|
||||
def test_to_server(self):
|
||||
wrapper = SimpleFilesPathWrapper(Path("/etc/telegram-bot-api/data"), Path("/opt/app/data"))
|
||||
assert wrapper.to_server("/opt/app/data/documents/file.dat") == Path(
|
||||
"/etc/telegram-bot-api/data/documents/file.dat"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue