@@ -688,12 +688,12 @@ def test_similar_dynamic_routes():
688
688
# r'^/accounts/(?P<account_id>\\w+\\b)$' # noqa: E800
689
689
@app .get ("/accounts/<account_id>" )
690
690
def get_account (account_id : str ):
691
- assert account_id in ( "single_account" , "single account" )
691
+ assert account_id == "single_account"
692
692
693
693
# r'^/accounts/(?P<account_id>\\w+\\b)/source_networks$' # noqa: E800
694
694
@app .get ("/accounts/<account_id>/source_networks" )
695
695
def get_account_networks (account_id : str ):
696
- assert account_id in ( "nested_account" , "nested account" )
696
+ assert account_id == "nested_account"
697
697
698
698
# r'^/accounts/(?P<account_id>\\w+\\b)/source_networks/(?P<network_id>\\w+\\b)$' # noqa: E800
699
699
@app .get ("/accounts/<account_id>/source_networks/<network_id>" )
@@ -706,20 +706,48 @@ def get_network_account(account_id: str, network_id: str):
706
706
event ["path" ] = "/accounts/single_account"
707
707
app .resolve (event , None )
708
708
709
- event ["resource" ] = "/accounts/{account_id}"
710
- event ["path" ] = "/accounts/single account"
711
- app .resolve (event , None )
712
-
713
709
event ["resource" ] = "/accounts/{account_id}/source_networks"
714
710
event ["path" ] = "/accounts/nested_account/source_networks"
715
711
app .resolve (event , None )
716
712
713
+ event ["resource" ] = "/accounts/{account_id}/source_networks/{network_id}"
714
+ event ["path" ] = "/accounts/nested_account/source_networks/network"
715
+ app .resolve (event , {})
716
+
717
+
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
+ app .resolve (event , None )
744
+
717
745
event ["resource" ] = "/accounts/{account_id}/source_networks"
718
746
event ["path" ] = "/accounts/nested account/source_networks"
719
747
app .resolve (event , None )
720
748
721
749
event ["resource" ] = "/accounts/{account_id}/source_networks/{network_id}"
722
- event ["path" ] = "/accounts/nested_account /source_networks/network"
750
+ event ["path" ] = "/accounts/nested account /source_networks/network 123 "
723
751
app .resolve (event , {})
724
752
725
753
0 commit comments