Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 7a87c41

Browse files
feat: add from_service_account_info factory and fix sphinx identifiers (#74)
feat: add 'from_service_account_info' factory to clients fix: fix sphinx identifiers PiperOrigin-RevId: 350246057 Source-Author: Google APIs <[email protected]> Source-Date: Tue Jan 5 16:44:11 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 520682435235d9c503983a360a2090025aa47cd1 Source-Link: googleapis/googleapis@5206824
1 parent 56c8daf commit 7a87c41

File tree

9 files changed

+316
-303
lines changed

9 files changed

+316
-303
lines changed

.coveragerc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ branch = True
44
[report]
55
fail_under = 100
66
show_missing = True
7-
omit = google/cloud/devtools/containeranalysis/__init__.py
7+
omit =
8+
google/cloud/devtools/containeranalysis/__init__.py
89
exclude_lines =
910
# Re-enable the standard pragma
1011
pragma: NO COVER
@@ -14,4 +15,4 @@ exclude_lines =
1415
# This is added at the module level as a safeguard for if someone
1516
# generates the code and tries to run it without pip installing. This
1617
# makes it virtually impossible to test properly.
17-
except pkg_resources.DistributionNotFound
18+
except pkg_resources.DistributionNotFound
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ContainerAnalysis
2+
-----------------------------------
3+
4+
.. automodule:: google.cloud.devtools.containeranalysis_v1.services.container_analysis
5+
:members:
6+
:inherited-members:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Services for Google Cloud Devtools Containeranalysis v1 API
22
===========================================================
3+
.. toctree::
4+
:maxdepth: 2
35

4-
.. automodule:: google.cloud.devtools.containeranalysis_v1.services.container_analysis
5-
:members:
6-
:inherited-members:
6+
container_analysis

docs/containeranalysis_v1/types.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Types for Google Cloud Devtools Containeranalysis v1 API
33

44
.. automodule:: google.cloud.devtools.containeranalysis_v1.types
55
:members:
6+
:undoc-members:
67
:show-inheritance:

google/cloud/devtools/containeranalysis_v1/services/container_analysis/async_client.py

Lines changed: 125 additions & 139 deletions
Large diffs are not rendered by default.

google/cloud/devtools/containeranalysis_v1/services/container_analysis/client.py

Lines changed: 149 additions & 148 deletions
Large diffs are not rendered by default.

google/cloud/devtools/containeranalysis_v1/types/containeranalysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class VulnerabilityOccurrencesSummary(proto.Message):
5252
resource and severity type.
5353
5454
Attributes:
55-
counts (Sequence[~.containeranalysis.VulnerabilityOccurrencesSummary.FixableTotalByDigest]):
55+
counts (Sequence[google.cloud.devtools.containeranalysis_v1.types.VulnerabilityOccurrencesSummary.FixableTotalByDigest]):
5656
A listing by resource of the number of
5757
fixable and total vulnerabilities.
5858
"""
@@ -64,7 +64,7 @@ class FixableTotalByDigest(proto.Message):
6464
Attributes:
6565
resource_uri (str):
6666
The affected resource.
67-
severity (~.vulnerability.Severity):
67+
severity (grafeas.v1.vulnerability_pb2.Severity):
6868
The severity for this count. SEVERITY_UNSPECIFIED indicates
6969
total across all severities.
7070
fixable_count (int):

synth.metadata

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/python-containeranalysis.git",
7-
"sha": "c7bbfa1b67df35cae8adb45f8b34aae3a45c6e3d"
7+
"sha": "56c8dafd3995079015f86119ae2d48bd50124ef3"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907",
15-
"internalRef": "347055288"
14+
"sha": "520682435235d9c503983a360a2090025aa47cd1",
15+
"internalRef": "350246057"
1616
}
1717
},
1818
{
@@ -42,6 +42,7 @@
4242
}
4343
],
4444
"generatedFiles": [
45+
".coveragerc",
4546
".flake8",
4647
".github/CONTRIBUTING.md",
4748
".github/ISSUE_TEMPLATE/bug_report.md",
@@ -94,6 +95,7 @@
9495
"docs/_static/custom.css",
9596
"docs/_templates/layout.html",
9697
"docs/conf.py",
98+
"docs/containeranalysis_v1/container_analysis.rst",
9799
"docs/containeranalysis_v1/services.rst",
98100
"docs/containeranalysis_v1/types.rst",
99101
"docs/multiprocessing.rst",

tests/unit/gapic/containeranalysis_v1/test_container_analysis.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,21 @@ def test__get_default_mtls_endpoint():
9494
)
9595

9696

97+
def test_container_analysis_client_from_service_account_info():
98+
creds = credentials.AnonymousCredentials()
99+
with mock.patch.object(
100+
service_account.Credentials, "from_service_account_info"
101+
) as factory:
102+
factory.return_value = creds
103+
info = {"valid": True}
104+
client = ContainerAnalysisClient.from_service_account_info(info)
105+
assert client.transport._credentials == creds
106+
107+
assert client.transport._host == "containeranalysis.googleapis.com:443"
108+
109+
97110
@pytest.mark.parametrize(
98-
"client_class", [ContainerAnalysisClient, ContainerAnalysisAsyncClient]
111+
"client_class", [ContainerAnalysisClient, ContainerAnalysisAsyncClient,]
99112
)
100113
def test_container_analysis_client_from_service_account_file(client_class):
101114
creds = credentials.AnonymousCredentials()
@@ -114,7 +127,10 @@ def test_container_analysis_client_from_service_account_file(client_class):
114127

115128
def test_container_analysis_client_get_transport_class():
116129
transport = ContainerAnalysisClient.get_transport_class()
117-
assert transport == transports.ContainerAnalysisGrpcTransport
130+
available_transports = [
131+
transports.ContainerAnalysisGrpcTransport,
132+
]
133+
assert transport in available_transports
118134

119135
transport = ContainerAnalysisClient.get_transport_class("grpc")
120136
assert transport == transports.ContainerAnalysisGrpcTransport
@@ -1526,7 +1542,7 @@ def test_container_analysis_host_with_port():
15261542

15271543

15281544
def test_container_analysis_grpc_transport_channel():
1529-
channel = grpc.insecure_channel("http://localhost/")
1545+
channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
15301546

15311547
# Check that channel is used if provided.
15321548
transport = transports.ContainerAnalysisGrpcTransport(
@@ -1538,7 +1554,7 @@ def test_container_analysis_grpc_transport_channel():
15381554

15391555

15401556
def test_container_analysis_grpc_asyncio_transport_channel():
1541-
channel = aio.insecure_channel("http://localhost/")
1557+
channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
15421558

15431559
# Check that channel is used if provided.
15441560
transport = transports.ContainerAnalysisGrpcAsyncIOTransport(
@@ -1563,7 +1579,7 @@ def test_container_analysis_transport_channel_mtls_with_client_cert_source(
15631579
"grpc.ssl_channel_credentials", autospec=True
15641580
) as grpc_ssl_channel_cred:
15651581
with mock.patch.object(
1566-
transport_class, "create_channel", autospec=True
1582+
transport_class, "create_channel"
15671583
) as grpc_create_channel:
15681584
mock_ssl_cred = mock.Mock()
15691585
grpc_ssl_channel_cred.return_value = mock_ssl_cred
@@ -1616,7 +1632,7 @@ def test_container_analysis_transport_channel_mtls_with_adc(transport_class):
16161632
ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
16171633
):
16181634
with mock.patch.object(
1619-
transport_class, "create_channel", autospec=True
1635+
transport_class, "create_channel"
16201636
) as grpc_create_channel:
16211637
mock_grpc_channel = mock.Mock()
16221638
grpc_create_channel.return_value = mock_grpc_channel

0 commit comments

Comments
 (0)