File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ localdeps =
77 pip install --quiet --upgrade {toxinidir}/../core
88deps =
99 pytest
10+ mock
1011covercmd =
1112 py.test --quiet \
1213 --cov =google.cloud.monitoring \
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments