@@ -715,6 +715,42 @@ def get_network_account(account_id: str, network_id: str):
715715 app .resolve (event , {})
716716
717717
718+ def test_similar_dynamic_routes_with_whitespaces ():
719+ # GIVEN
720+ app = ApiGatewayResolver ()
721+ event = deepcopy (LOAD_GW_EVENT )
722+
723+ # WHEN
724+ # r'^/accounts/(?P<account_id>\\w+\\b)$' # noqa: E800
725+ @app .get ("/accounts/<account_id>" )
726+ def get_account (account_id : str ):
727+ assert account_id == "single account"
728+
729+ # r'^/accounts/(?P<account_id>\\w+\\b)/source_networks$' # noqa: E800
730+ @app .get ("/accounts/<account_id>/source_networks" )
731+ def get_account_networks (account_id : str ):
732+ assert account_id == "nested account"
733+
734+ # r'^/accounts/(?P<account_id>\\w+\\b)/source_networks/(?P<network_id>\\w+\\b)$' # noqa: E800
735+ @app .get ("/accounts/<account_id>/source_networks/<network_id>" )
736+ def get_network_account (account_id : str , network_id : str ):
737+ assert account_id == "nested account"
738+ assert network_id == "network 123"
739+
740+ # THEN
741+ event ["resource" ] = "/accounts/{account_id}"
742+ event ["path" ] = "/accounts/single account"
743+ assert app .resolve (event , {})["statusCode" ] == 200
744+
745+ event ["resource" ] = "/accounts/{account_id}/source_networks"
746+ event ["path" ] = "/accounts/nested account/source_networks"
747+ assert app .resolve (event , {})["statusCode" ] == 200
748+
749+ event ["resource" ] = "/accounts/{account_id}/source_networks/{network_id}"
750+ event ["path" ] = "/accounts/nested account/source_networks/network 123"
751+ assert app .resolve (event , {})["statusCode" ] == 200
752+
753+
718754@pytest .mark .parametrize (
719755 "req" ,
720756 [
0 commit comments