Skip to content

Commit f8e9679

Browse files
committed
Swap _Monkey for mock.patch().
1 parent 0291dd4 commit f8e9679

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

monitoring/tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ localdeps =
77
pip install --quiet --upgrade {toxinidir}/../core
88
deps =
99
pytest
10+
mock
1011
covercmd =
1112
py.test --quiet \
1213
--cov=google.cloud.monitoring \

monitoring/unit_tests/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ def test_resource_factory(self):
185185

186186
def test_timeseries_factory_gauge(self):
187187
import datetime
188-
from google.cloud._testing import _Monkey
189-
import google.cloud.monitoring.client
188+
import mock
190189
from google.cloud._helpers import _datetime_to_rfc3339
191190
METRIC_TYPE = 'custom.googleapis.com/my_metric'
192191
METRIC_LABELS = {
@@ -222,7 +221,8 @@ def test_timeseries_factory_gauge(self):
222221
TIME2_STR = _datetime_to_rfc3339(TIME2, ignore_zone=False)
223222
# Construct a time series assuming a gauge metric using the current
224223
# time
225-
with _Monkey(google.cloud.monitoring.client, _UTCNOW=lambda: TIME2):
224+
with mock.patch('google.cloud.monitoring.client._UTCNOW',
225+
new=lambda: TIME2):
226226
timeseries_no_end = client.time_series(metric, resource, VALUE)
227227

228228
self.assertEqual(timeseries_no_end.points[0].end_time, TIME2_STR)

monitoring/unit_tests/test_query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def test_constructor_maximal(self):
129129

130130
def test_constructor_default_end_time(self):
131131
import datetime
132-
from google.cloud._testing import _Monkey
133-
from google.cloud.monitoring import query as MUT
132+
import mock
134133

135134
MINUTES = 5
136135
NOW, T0, T1 = [
@@ -140,7 +139,8 @@ def test_constructor_default_end_time(self):
140139
]
141140

142141
client = _Client(project=PROJECT, connection=_Connection())
143-
with _Monkey(MUT, _UTCNOW=lambda: NOW):
142+
with mock.patch('google.cloud.monitoring.query._UTCNOW',
143+
new=lambda: NOW):
144144
query = self._make_one(client, METRIC_TYPE, minutes=MINUTES)
145145

146146
self.assertEqual(query._start_time, T0)

0 commit comments

Comments
 (0)