From 98f81e0377eb27bb26eb03d3d2c31229252b99af Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 29 May 2020 16:06:00 -0700 Subject: [PATCH] chore: re-order methods (#14) --- .../services/reservation_service/client.py | 50 ++++++------- .../synth.metadata | 9 ++- .../test_reservation_service.py | 70 +++++++++---------- 3 files changed, 68 insertions(+), 61 deletions(-) diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py index e1e63e1efa2b..5a1c0941d7f5 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py @@ -147,17 +147,19 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file @staticmethod - def bi_reservation_path(project: str, location: str) -> str: - """Return a fully-qualified bi_reservation string.""" - return "projects/{project}/locations/{location}/bireservation".format( - project=project, location=location + def capacity_commitment_path( + project: str, location: str, capacity_commitment: str + ) -> str: + """Return a fully-qualified capacity_commitment string.""" + return "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( + project=project, location=location, capacity_commitment=capacity_commitment ) @staticmethod - def parse_bi_reservation_path(path: str) -> Dict[str, str]: - """Parse a bi_reservation path into its component segments.""" + def parse_capacity_commitment_path(path: str) -> Dict[str, str]: + """Parse a capacity_commitment path into its component segments.""" m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/bireservation$", + r"^projects/(?P.+?)/locations/(?P.+?)/capacityCommitments/(?P.+?)$", path, ) return m.groupdict() if m else {} @@ -178,6 +180,22 @@ def parse_reservation_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def bi_reservation_path(project: str, location: str) -> str: + """Return a fully-qualified bi_reservation string.""" + return "projects/{project}/locations/{location}/bireservation".format( + project=project, location=location + ) + + @staticmethod + def parse_bi_reservation_path(path: str) -> Dict[str, str]: + """Parse a bi_reservation path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/bireservation$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def assignment_path( project: str, location: str, reservation: str, assignment: str @@ -199,24 +217,6 @@ def parse_assignment_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} - @staticmethod - def capacity_commitment_path( - project: str, location: str, capacity_commitment: str - ) -> str: - """Return a fully-qualified capacity_commitment string.""" - return "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( - project=project, location=location, capacity_commitment=capacity_commitment - ) - - @staticmethod - def parse_capacity_commitment_path(path: str) -> Dict[str, str]: - """Parse a capacity_commitment path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/capacityCommitments/(?P.+?)$", - path, - ) - return m.groupdict() if m else {} - def __init__( self, *, diff --git a/packages/google-cloud-bigquery-reservation/synth.metadata b/packages/google-cloud-bigquery-reservation/synth.metadata index 1a46165bf85f..1213436106b2 100644 --- a/packages/google-cloud-bigquery-reservation/synth.metadata +++ b/packages/google-cloud-bigquery-reservation/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-bigquery-reservation.git", - "sha": "bd99c23ca4b29514be055cd949e24cdf2d422519" + "sha": "4210d3c3e198d5c2220b9590e77df4f5712109b6" } }, { @@ -15,6 +15,13 @@ "internalRef": "313488995" } }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "71b8a272549c06b5768d00fa48d3ae990e871bec" + } + }, { "git": { "name": "synthtool", diff --git a/packages/google-cloud-bigquery-reservation/tests/unit/reservation_v1/test_reservation_service.py b/packages/google-cloud-bigquery-reservation/tests/unit/reservation_v1/test_reservation_service.py index 5dcfb24b1a88..5829cd470d86 100644 --- a/packages/google-cloud-bigquery-reservation/tests/unit/reservation_v1/test_reservation_service.py +++ b/packages/google-cloud-bigquery-reservation/tests/unit/reservation_v1/test_reservation_service.py @@ -2083,23 +2083,30 @@ def test_reservation_service_grpc_transport_channel_mtls_with_adc( assert transport.grpc_channel == mock_grpc_channel -def test_bi_reservation_path(): +def test_capacity_commitment_path(): project = "squid" location = "clam" + capacity_commitment = "whelk" - expected = "projects/{project}/locations/{location}/bireservation".format( - project=project, location=location + expected = "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( + project=project, location=location, capacity_commitment=capacity_commitment + ) + actual = ReservationServiceClient.capacity_commitment_path( + project, location, capacity_commitment ) - actual = ReservationServiceClient.bi_reservation_path(project, location) assert expected == actual -def test_parse_bi_reservation_path(): - expected = {"project": "whelk", "location": "octopus"} - path = ReservationServiceClient.bi_reservation_path(**expected) +def test_parse_capacity_commitment_path(): + expected = { + "project": "octopus", + "location": "oyster", + "capacity_commitment": "nudibranch", + } + path = ReservationServiceClient.capacity_commitment_path(**expected) # Check that the path construction is reversible. - actual = ReservationServiceClient.parse_bi_reservation_path(path) + actual = ReservationServiceClient.parse_capacity_commitment_path(path) assert expected == actual @@ -2124,6 +2131,26 @@ def test_parse_reservation_path(): assert expected == actual +def test_bi_reservation_path(): + project = "squid" + location = "clam" + + expected = "projects/{project}/locations/{location}/bireservation".format( + project=project, location=location + ) + actual = ReservationServiceClient.bi_reservation_path(project, location) + assert expected == actual + + +def test_parse_bi_reservation_path(): + expected = {"project": "whelk", "location": "octopus"} + path = ReservationServiceClient.bi_reservation_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_bi_reservation_path(path) + assert expected == actual + + def test_assignment_path(): project = "squid" location = "clam" @@ -2154,30 +2181,3 @@ def test_parse_assignment_path(): # Check that the path construction is reversible. actual = ReservationServiceClient.parse_assignment_path(path) assert expected == actual - - -def test_capacity_commitment_path(): - project = "squid" - location = "clam" - capacity_commitment = "whelk" - - expected = "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( - project=project, location=location, capacity_commitment=capacity_commitment - ) - actual = ReservationServiceClient.capacity_commitment_path( - project, location, capacity_commitment - ) - assert expected == actual - - -def test_parse_capacity_commitment_path(): - expected = { - "project": "octopus", - "location": "oyster", - "capacity_commitment": "nudibranch", - } - path = ReservationServiceClient.capacity_commitment_path(**expected) - - # Check that the path construction is reversible. - actual = ReservationServiceClient.parse_capacity_commitment_path(path) - assert expected == actual