Skip to content

Commit

Permalink
Fix: this commit resolve airtai#1765 (airtai#1789)
Browse files Browse the repository at this point in the history
* Fix: this commit resolve airtai#1765

* tests: refactor test

---------

Co-authored-by: Daniil Dumchenko <dumchenko.de@sibvaleo.com>
Co-authored-by: Nikita Pastukhov <diementros@yandex.ru>
  • Loading branch information
3 people authored Sep 13, 2024
1 parent 6a06a38 commit 183dee4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion faststream/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def compile_path(
replace_symbol: str,
patch_regex: Callable[[str], str] = lambda x: x,
) -> Tuple[Optional[Pattern[str]], str]:
path_regex = "^.*"
path_regex = "^.*?"
original_path = ""

idx = 0
Expand Down
24 changes: 24 additions & 0 deletions tests/brokers/nats/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ async def h(
assert event.is_set()
mock.assert_called_once_with(name="john", id=2)

async def test_path_as_first_with_prefix(
self,
event,
mock,
router: NatsRouter,
pub_broker,
):
router.prefix = "root."

@router.subscriber("{name}.nested")
async def h(name: str = Path()):
event.set()
mock(name=name)

pub_broker._is_apply_types = True
pub_broker.include_router(router)

await pub_broker.start()

await pub_broker.publish("", "root.john.nested", rpc=True)

assert event.is_set()
mock.assert_called_once_with(name="john")

async def test_router_path_with_prefix(
self,
event,
Expand Down

0 comments on commit 183dee4

Please sign in to comment.