Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
chore: change order of resource path helper methods (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Jun 1, 2020
1 parent 1b85e6c commit a7260ef
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
Expand Up @@ -134,37 +134,37 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file

@staticmethod
def game_server_deployment_path(
def game_server_deployment_rollout_path(
project: str, location: str, deployment: str
) -> str:
"""Return a fully-qualified game_server_deployment string."""
return "projects/{project}/locations/{location}/gameServerDeployments/{deployment}".format(
"""Return a fully-qualified game_server_deployment_rollout string."""
return "projects/{project}/locations/{location}/gameServerDeployments/{deployment}/rollout".format(
project=project, location=location, deployment=deployment
)

@staticmethod
def parse_game_server_deployment_path(path: str) -> Dict[str, str]:
"""Parse a game_server_deployment path into its component segments."""
def parse_game_server_deployment_rollout_path(path: str) -> Dict[str, str]:
"""Parse a game_server_deployment_rollout path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/gameServerDeployments/(?P<deployment>.+?)$",
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/gameServerDeployments/(?P<deployment>.+?)/rollout$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def game_server_deployment_rollout_path(
def game_server_deployment_path(
project: str, location: str, deployment: str
) -> str:
"""Return a fully-qualified game_server_deployment_rollout string."""
return "projects/{project}/locations/{location}/gameServerDeployments/{deployment}/rollout".format(
"""Return a fully-qualified game_server_deployment string."""
return "projects/{project}/locations/{location}/gameServerDeployments/{deployment}".format(
project=project, location=location, deployment=deployment
)

@staticmethod
def parse_game_server_deployment_rollout_path(path: str) -> Dict[str, str]:
"""Parse a game_server_deployment_rollout path into its component segments."""
def parse_game_server_deployment_path(path: str) -> Dict[str, str]:
"""Parse a game_server_deployment path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/gameServerDeployments/(?P<deployment>.+?)/rollout$",
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/gameServerDeployments/(?P<deployment>.+?)$",
path,
)
return m.groupdict() if m else {}
Expand Down
13 changes: 10 additions & 3 deletions synth.metadata
Expand Up @@ -4,15 +4,22 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-game-servers.git",
"sha": "3528a72c887b51b2dd0484869d028ed8f98c8c79"
"sha": "1b85e6c6523fc588f235fd9e320238101c63fade"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "eafa840ceec23b44a5c21670288107c661252711",
"internalRef": "313488995"
"sha": "fb21971becb6c0441efc855dabc371825732872c",
"internalRef": "313812131"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "71b8a272549c06b5768d00fa48d3ae990e871bec"
}
},
{
Expand Down
32 changes: 16 additions & 16 deletions tests/unit/gaming_v1/test_game_server_deployments_service.py
Expand Up @@ -1108,51 +1108,51 @@ def test_game_server_deployments_service_grpc_lro_client():
assert transport.operations_client is transport.operations_client


def test_game_server_deployment_path():
def test_game_server_deployment_rollout_path():
project = "squid"
location = "clam"
deployment = "whelk"

expected = "projects/{project}/locations/{location}/gameServerDeployments/{deployment}".format(
expected = "projects/{project}/locations/{location}/gameServerDeployments/{deployment}/rollout".format(
project=project, location=location, deployment=deployment
)
actual = GameServerDeploymentsServiceClient.game_server_deployment_path(
actual = GameServerDeploymentsServiceClient.game_server_deployment_rollout_path(
project, location, deployment
)
assert expected == actual


def test_parse_game_server_deployment_path():
def test_parse_game_server_deployment_rollout_path():
expected = {"project": "octopus", "location": "oyster", "deployment": "nudibranch"}
path = GameServerDeploymentsServiceClient.game_server_deployment_path(**expected)
path = GameServerDeploymentsServiceClient.game_server_deployment_rollout_path(
**expected
)

# Check that the path construction is reversible.
actual = GameServerDeploymentsServiceClient.parse_game_server_deployment_path(path)
actual = GameServerDeploymentsServiceClient.parse_game_server_deployment_rollout_path(
path
)
assert expected == actual


def test_game_server_deployment_rollout_path():
def test_game_server_deployment_path():
project = "squid"
location = "clam"
deployment = "whelk"

expected = "projects/{project}/locations/{location}/gameServerDeployments/{deployment}/rollout".format(
expected = "projects/{project}/locations/{location}/gameServerDeployments/{deployment}".format(
project=project, location=location, deployment=deployment
)
actual = GameServerDeploymentsServiceClient.game_server_deployment_rollout_path(
actual = GameServerDeploymentsServiceClient.game_server_deployment_path(
project, location, deployment
)
assert expected == actual


def test_parse_game_server_deployment_rollout_path():
def test_parse_game_server_deployment_path():
expected = {"project": "octopus", "location": "oyster", "deployment": "nudibranch"}
path = GameServerDeploymentsServiceClient.game_server_deployment_rollout_path(
**expected
)
path = GameServerDeploymentsServiceClient.game_server_deployment_path(**expected)

# Check that the path construction is reversible.
actual = GameServerDeploymentsServiceClient.parse_game_server_deployment_rollout_path(
path
)
actual = GameServerDeploymentsServiceClient.parse_game_server_deployment_path(path)
assert expected == actual

0 comments on commit a7260ef

Please sign in to comment.