Skip to content

Commit 45a7588

Browse files
committed
pull whitespace path param in own test
1 parent e9530c8 commit 45a7588

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

tests/functional/event_handler/test_api_gateway.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,12 +688,12 @@ def test_similar_dynamic_routes():
688688
# r'^/accounts/(?P<account_id>\\w+\\b)$' # noqa: E800
689689
@app.get("/accounts/<account_id>")
690690
def get_account(account_id: str):
691-
assert account_id in ("single_account", "single account")
691+
assert account_id == "single_account"
692692

693693
# r'^/accounts/(?P<account_id>\\w+\\b)/source_networks$' # noqa: E800
694694
@app.get("/accounts/<account_id>/source_networks")
695695
def get_account_networks(account_id: str):
696-
assert account_id in ("nested_account", "nested account")
696+
assert account_id == "nested_account"
697697

698698
# r'^/accounts/(?P<account_id>\\w+\\b)/source_networks/(?P<network_id>\\w+\\b)$' # noqa: E800
699699
@app.get("/accounts/<account_id>/source_networks/<network_id>")
@@ -706,20 +706,48 @@ def get_network_account(account_id: str, network_id: str):
706706
event["path"] = "/accounts/single_account"
707707
app.resolve(event, None)
708708

709-
event["resource"] = "/accounts/{account_id}"
710-
event["path"] = "/accounts/single account"
711-
app.resolve(event, None)
712-
713709
event["resource"] = "/accounts/{account_id}/source_networks"
714710
event["path"] = "/accounts/nested_account/source_networks"
715711
app.resolve(event, None)
716712

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+
717745
event["resource"] = "/accounts/{account_id}/source_networks"
718746
event["path"] = "/accounts/nested account/source_networks"
719747
app.resolve(event, None)
720748

721749
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"
723751
app.resolve(event, {})
724752

725753

0 commit comments

Comments
 (0)