Skip to content

Commit

Permalink
Merge branch 'airtai:main' into asgi-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sehat1137 authored Sep 16, 2024
2 parents 287e9b0 + 183dee4 commit 323e3e0
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 323e3e0

Please sign in to comment.