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

Commit

Permalink
docs: update python docs template (#576) (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Jun 1, 2020
1 parent 7324dab commit e2ebb9a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 30 deletions.
Expand Up @@ -128,17 +128,6 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):

from_service_account_json = from_service_account_file

@staticmethod
def key_path(project: str, key: str) -> str:
"""Return a fully-qualified key string."""
return "projects/{project}/keys/{key}".format(project=project, key=key)

@staticmethod
def parse_key_path(path: str) -> Dict[str, str]:
"""Parse a key path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/keys/(?P<key>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def assessment_path(project: str, assessment: str) -> str:
"""Return a fully-qualified assessment string."""
Expand All @@ -154,6 +143,17 @@ def parse_assessment_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def key_path(project: str, key: str) -> str:
"""Return a fully-qualified key string."""
return "projects/{project}/keys/{key}".format(project=project, key=key)

@staticmethod
def parse_key_path(path: str) -> Dict[str, str]:
"""Parse a key path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/keys/(?P<key>.+?)$", path)
return m.groupdict() if m else {}

def __init__(
self,
*,
Expand Down
9 changes: 8 additions & 1 deletion synth.metadata
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-recaptcha-enterprise.git",
"sha": "7c33a9920ae55449bc2759cedf39c2d7f572ef48"
"sha": "7324dab498edf1e202eec05d3c85efb7cd9d2d43"
}
},
{
Expand All @@ -15,6 +15,13 @@
"internalRef": "313488995"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "71b8a272549c06b5768d00fa48d3ae990e871bec"
}
},
{
"git": {
"name": "synthtool",
Expand Down
Expand Up @@ -749,24 +749,6 @@ def test_recaptcha_enterprise_service_grpc_transport_channel_mtls_with_adc(
assert transport.grpc_channel == mock_grpc_channel


def test_key_path():
project = "squid"
key = "clam"

expected = "projects/{project}/keys/{key}".format(project=project, key=key)
actual = RecaptchaEnterpriseServiceClient.key_path(project, key)
assert expected == actual


def test_parse_key_path():
expected = {"project": "whelk", "key": "octopus"}
path = RecaptchaEnterpriseServiceClient.key_path(**expected)

# Check that the path construction is reversible.
actual = RecaptchaEnterpriseServiceClient.parse_key_path(path)
assert expected == actual


def test_assessment_path():
project = "squid"
assessment = "clam"
Expand All @@ -785,3 +767,21 @@ def test_parse_assessment_path():
# Check that the path construction is reversible.
actual = RecaptchaEnterpriseServiceClient.parse_assessment_path(path)
assert expected == actual


def test_key_path():
project = "squid"
key = "clam"

expected = "projects/{project}/keys/{key}".format(project=project, key=key)
actual = RecaptchaEnterpriseServiceClient.key_path(project, key)
assert expected == actual


def test_parse_key_path():
expected = {"project": "whelk", "key": "octopus"}
path = RecaptchaEnterpriseServiceClient.key_path(**expected)

# Check that the path construction is reversible.
actual = RecaptchaEnterpriseServiceClient.parse_key_path(path)
assert expected == actual

0 comments on commit e2ebb9a

Please sign in to comment.