Skip to content

Commit

Permalink
Merge pull request #2655 from dhermes/use-gax-logging-oops
Browse files Browse the repository at this point in the history
Using Logging client's use_gax attr. in API properties.
  • Loading branch information
dhermes authored Oct 31, 2016
2 parents 6842d49 + cd42824 commit 9498fe5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions logging/google/cloud/logging/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def sinks_api(self):
https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks
"""
if self._sinks_api is None:
if _USE_GAX:
if self._use_gax:
generated = GeneratedSinksAPI()
self._sinks_api = GAXSinksAPI(generated, self)
else:
Expand All @@ -126,7 +126,7 @@ def metrics_api(self):
https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics
"""
if self._metrics_api is None:
if _USE_GAX:
if self._use_gax:
generated = GeneratedMetricsAPI()
self._metrics_api = GAXMetricsAPI(generated, self)
else:
Expand Down
14 changes: 8 additions & 6 deletions logging/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ def test_sinks_api_wo_gax(self):
from google.cloud.logging.connection import _SinksAPI
from google.cloud.logging import client as MUT
from google.cloud._testing import _Monkey
client = self._makeOne(self.PROJECT, credentials=_Credentials())
conn = client.connection = object()

with _Monkey(MUT, _USE_GAX=False):
api = client.sinks_api
client = self._makeOne(self.PROJECT, credentials=_Credentials())

conn = client.connection = object()
api = client.sinks_api

self.assertIsInstance(api, _SinksAPI)
self.assertIs(api._connection, conn)
Expand Down Expand Up @@ -153,11 +154,12 @@ def test_metrics_api_wo_gax(self):
from google.cloud.logging.connection import _MetricsAPI
from google.cloud.logging import client as MUT
from google.cloud._testing import _Monkey
client = self._makeOne(self.PROJECT, credentials=_Credentials())
conn = client.connection = object()

with _Monkey(MUT, _USE_GAX=False):
api = client.metrics_api
client = self._makeOne(self.PROJECT, credentials=_Credentials())

conn = client.connection = object()
api = client.metrics_api

self.assertIsInstance(api, _MetricsAPI)
self.assertIs(api._connection, conn)
Expand Down

0 comments on commit 9498fe5

Please sign in to comment.