mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 01:54:53 +00:00
Add possibility to include router via string
This commit is contained in:
parent
b943ea2207
commit
dadedc80a9
6 changed files with 86 additions and 3 deletions
|
|
@ -20,6 +20,8 @@ from aiogram.api.types import (
|
|||
from aiogram.dispatcher.event.observer import SkipHandler
|
||||
from aiogram.dispatcher.router import Router
|
||||
|
||||
importable_router = Router()
|
||||
|
||||
|
||||
class TestRouter:
|
||||
def test_including_routers(self):
|
||||
|
|
@ -50,6 +52,15 @@ class TestRouter:
|
|||
assert router3.parent_router is router2
|
||||
assert router3.sub_routers == []
|
||||
|
||||
def test_include_router_by_string(self):
|
||||
router = Router()
|
||||
router.include_router("tests.test_dispatcher.test_router:importable_router")
|
||||
|
||||
def test_include_router_by_string_bad_type(self):
|
||||
router = Router()
|
||||
with pytest.raises(ValueError, match=r"router should be instance of Router"):
|
||||
router.include_router("tests.test_dispatcher.test_router:TestRouter")
|
||||
|
||||
def test_observers_config(self):
|
||||
router = Router()
|
||||
assert router.update_handler.handlers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue