Skip to content

Commit 4b29950

Browse files
committed
Moving test _helpers back into library.
This is preparation for subpackage split-up.
1 parent 2f8b811 commit 4b29950

25 files changed

+160
-160
lines changed

unit_tests/bigquery/test_table.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ def test_upload_from_file_multipart_w_400(self):
14651465
import csv
14661466
import datetime
14671467
from six.moves.http_client import BAD_REQUEST
1468-
from unit_tests._testing import _NamedTemporaryFile
1468+
from google.cloud._testing import _NamedTemporaryFile
14691469
from google.cloud._helpers import UTC
14701470
from google.cloud.exceptions import BadRequest
14711471
WHEN_TS = 1437767599.006
@@ -1495,7 +1495,7 @@ def _upload_from_file_helper(self, **kw):
14951495
import datetime
14961496
from six.moves.http_client import OK
14971497
from google.cloud._helpers import UTC
1498-
from unit_tests._testing import _NamedTemporaryFile
1498+
from google.cloud._testing import _NamedTemporaryFile
14991499
from google.cloud.bigquery.table import SchemaField
15001500

15011501
WHEN_TS = 1437767599.006
@@ -1604,8 +1604,8 @@ def test_upload_from_file_resumable_with_400(self):
16041604
from google.cloud.bigquery import table as MUT
16051605
from google.cloud.exceptions import BadRequest
16061606
from google.cloud._helpers import UTC
1607-
from unit_tests._testing import _Monkey
1608-
from unit_tests._testing import _NamedTemporaryFile
1607+
from google.cloud._testing import _Monkey
1608+
from google.cloud._testing import _NamedTemporaryFile
16091609
WHEN_TS = 1437767599.006
16101610
WHEN = datetime.datetime.utcfromtimestamp(WHEN_TS).replace(
16111611
tzinfo=UTC)
@@ -1643,7 +1643,7 @@ def test_upload_from_file_w_explicit_client_resumable(self):
16431643
from six.moves.http_client import OK
16441644
from six.moves.urllib.parse import parse_qsl
16451645
from six.moves.urllib.parse import urlsplit
1646-
from unit_tests._testing import _Monkey
1646+
from google.cloud._testing import _Monkey
16471647
from google.cloud.bigquery import table as MUT
16481648

16491649
UPLOAD_PATH = 'https://example.com/upload/test'

unit_tests/bigtable/test_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _callFUT(self, client):
2323
return _make_data_stub(client)
2424

2525
def test_without_emulator(self):
26-
from unit_tests._testing import _Monkey
26+
from google.cloud._testing import _Monkey
2727
from google.cloud.bigtable import client as MUT
2828

2929
credentials = _Credentials()
@@ -51,7 +51,7 @@ def mock_make_secure_stub(*args):
5151
])
5252

5353
def test_with_emulator(self):
54-
from unit_tests._testing import _Monkey
54+
from google.cloud._testing import _Monkey
5555
from google.cloud.bigtable import client as MUT
5656

5757
emulator_host = object()
@@ -83,7 +83,7 @@ def _callFUT(self, client):
8383
return _make_instance_stub(client)
8484

8585
def test_without_emulator(self):
86-
from unit_tests._testing import _Monkey
86+
from google.cloud._testing import _Monkey
8787
from google.cloud.bigtable import client as MUT
8888

8989
credentials = _Credentials()
@@ -111,7 +111,7 @@ def mock_make_secure_stub(*args):
111111
])
112112

113113
def test_with_emulator(self):
114-
from unit_tests._testing import _Monkey
114+
from google.cloud._testing import _Monkey
115115
from google.cloud.bigtable import client as MUT
116116

117117
emulator_host = object()
@@ -143,7 +143,7 @@ def _callFUT(self, client):
143143
return _make_operations_stub(client)
144144

145145
def test_without_emulator(self):
146-
from unit_tests._testing import _Monkey
146+
from google.cloud._testing import _Monkey
147147
from google.cloud.bigtable import client as MUT
148148

149149
credentials = _Credentials()
@@ -171,7 +171,7 @@ def mock_make_secure_stub(*args):
171171
])
172172

173173
def test_with_emulator(self):
174-
from unit_tests._testing import _Monkey
174+
from google.cloud._testing import _Monkey
175175
from google.cloud.bigtable import client as MUT
176176

177177
emulator_host = object()
@@ -203,7 +203,7 @@ def _callFUT(self, client):
203203
return _make_table_stub(client)
204204

205205
def test_without_emulator(self):
206-
from unit_tests._testing import _Monkey
206+
from google.cloud._testing import _Monkey
207207
from google.cloud.bigtable import client as MUT
208208

209209
credentials = _Credentials()
@@ -231,7 +231,7 @@ def mock_make_secure_stub(*args):
231231
])
232232

233233
def test_with_emulator(self):
234-
from unit_tests._testing import _Monkey
234+
from google.cloud._testing import _Monkey
235235
from google.cloud.bigtable import client as MUT
236236

237237
emulator_host = object()
@@ -271,7 +271,7 @@ def _makeOne(self, *args, **kwargs):
271271
return self._getTargetClass()(*args, **kwargs)
272272

273273
def _makeOneWithMocks(self, *args, **kwargs):
274-
from unit_tests._testing import _Monkey
274+
from google.cloud._testing import _Monkey
275275
from google.cloud.bigtable import client as MUT
276276

277277
mock_make_data_stub = _MakeStubMock()
@@ -287,7 +287,7 @@ def _makeOneWithMocks(self, *args, **kwargs):
287287
def _constructor_test_helper(self, expected_scopes, creds,
288288
read_only=False, admin=False,
289289
user_agent=None, expected_creds=None):
290-
from unit_tests._testing import _Monkey
290+
from google.cloud._testing import _Monkey
291291
from google.cloud.bigtable import client as MUT
292292

293293
user_agent = user_agent or MUT.DEFAULT_USER_AGENT
@@ -373,7 +373,7 @@ def test_constructor_both_admin_and_read_only(self):
373373
read_only=True)
374374

375375
def test_constructor_implicit_credentials(self):
376-
from unit_tests._testing import _Monkey
376+
from google.cloud._testing import _Monkey
377377
from google.cloud.bigtable import client as MUT
378378

379379
creds = _Credentials()
@@ -392,7 +392,7 @@ def test_constructor_credentials_wo_create_scoped(self):
392392
self._constructor_test_helper(expected_scopes, creds)
393393

394394
def _copy_test_helper(self, read_only=False, admin=False):
395-
from unit_tests._testing import _Monkey
395+
from google.cloud._testing import _Monkey
396396
from google.cloud.bigtable import client as MUT
397397

398398
credentials = _Credentials('value')

unit_tests/bigtable/test_row.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def test_commit(self):
343343
self.assertEqual(row._pb_mutations, [])
344344

345345
def test_commit_too_many_mutations(self):
346-
from unit_tests._testing import _Monkey
346+
from google.cloud._testing import _Monkey
347347
from google.cloud.bigtable import row as MUT
348348

349349
row_key = b'row_key'
@@ -481,7 +481,7 @@ def test_commit(self):
481481
self.assertEqual(row._false_pb_mutations, [])
482482

483483
def test_commit_too_many_mutations(self):
484-
from unit_tests._testing import _Monkey
484+
from google.cloud._testing import _Monkey
485485
from google.cloud.bigtable import row as MUT
486486

487487
row_key = b'row_key'
@@ -572,7 +572,7 @@ def test_increment_cell_value(self):
572572
self.assertEqual(row._rule_pb_list, [expected_pb])
573573

574574
def test_commit(self):
575-
from unit_tests._testing import _Monkey
575+
from google.cloud._testing import _Monkey
576576
from unit_tests.bigtable._testing import _FakeStub
577577
from google.cloud.bigtable import row as MUT
578578

@@ -646,7 +646,7 @@ def test_commit_no_rules(self):
646646
self.assertEqual(stub.method_calls, [])
647647

648648
def test_commit_too_many_mutations(self):
649-
from unit_tests._testing import _Monkey
649+
from google.cloud._testing import _Monkey
650650
from google.cloud.bigtable import row as MUT
651651

652652
row_key = b'row_key'

unit_tests/bigtable/test_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def test_delete(self):
267267
)])
268268

269269
def _read_row_helper(self, chunks, expected_result):
270-
from unit_tests._testing import _Monkey
270+
from google.cloud._testing import _Monkey
271271
from unit_tests.bigtable._testing import _FakeStub
272272
from google.cloud.bigtable import table as MUT
273273

@@ -347,7 +347,7 @@ def test_read_row_still_partial(self):
347347
self._read_row_helper(chunks, None)
348348

349349
def test_read_rows(self):
350-
from unit_tests._testing import _Monkey
350+
from google.cloud._testing import _Monkey
351351
from unit_tests.bigtable._testing import _FakeStub
352352
from google.cloud.bigtable.row_data import PartialRowsData
353353
from google.cloud.bigtable import table as MUT

unit_tests/datastore/test_client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _callFUT(self):
3939

4040
def test_no_value(self):
4141
import os
42-
from unit_tests._testing import _Monkey
42+
from google.cloud._testing import _Monkey
4343

4444
environ = {}
4545
with _Monkey(os, getenv=environ.get):
@@ -48,7 +48,7 @@ def test_no_value(self):
4848

4949
def test_value_set(self):
5050
import os
51-
from unit_tests._testing import _Monkey
51+
from google.cloud._testing import _Monkey
5252
from google.cloud.datastore.client import GCD_DATASET
5353

5454
MOCK_PROJECT = object()
@@ -67,7 +67,7 @@ def _callFUT(self, project=None):
6767

6868
def _determine_default_helper(self, gcd=None, fallback=None,
6969
project_called=None):
70-
from unit_tests._testing import _Monkey
70+
from google.cloud._testing import _Monkey
7171
from google.cloud.datastore import client
7272

7373
_callers = []
@@ -140,7 +140,7 @@ def _makeOne(self, project=PROJECT, namespace=None,
140140
http=http)
141141

142142
def test_ctor_w_project_no_environ(self):
143-
from unit_tests._testing import _Monkey
143+
from google.cloud._testing import _Monkey
144144
from google.cloud.datastore import client as _MUT
145145

146146
# Some environments (e.g. AppVeyor CI) run in GCE, so
@@ -149,7 +149,7 @@ def test_ctor_w_project_no_environ(self):
149149
self.assertRaises(EnvironmentError, self._makeOne, None)
150150

151151
def test_ctor_w_implicit_inputs(self):
152-
from unit_tests._testing import _Monkey
152+
from google.cloud._testing import _Monkey
153153
from google.cloud.datastore import client as _MUT
154154
from google.cloud import client as _base_client
155155

@@ -494,7 +494,7 @@ def test_get_multi_hit_multiple_keys_different_project(self):
494494
client.get_multi([key1, key2])
495495

496496
def test_get_multi_max_loops(self):
497-
from unit_tests._testing import _Monkey
497+
from google.cloud._testing import _Monkey
498498
from google.cloud.datastore import client as _MUT
499499
from google.cloud.datastore.key import Key
500500

@@ -702,7 +702,7 @@ def test_key_w_project(self):
702702

703703
def test_key_wo_project(self):
704704
from google.cloud.datastore import client as MUT
705-
from unit_tests._testing import _Monkey
705+
from google.cloud._testing import _Monkey
706706

707707
KIND = 'KIND'
708708
ID = 1234
@@ -723,7 +723,7 @@ def test_key_wo_project(self):
723723

724724
def test_key_w_namespace(self):
725725
from google.cloud.datastore import client as MUT
726-
from unit_tests._testing import _Monkey
726+
from google.cloud._testing import _Monkey
727727

728728
KIND = 'KIND'
729729
ID = 1234
@@ -744,7 +744,7 @@ def test_key_w_namespace(self):
744744

745745
def test_key_w_namespace_collision(self):
746746
from google.cloud.datastore import client as MUT
747-
from unit_tests._testing import _Monkey
747+
from google.cloud._testing import _Monkey
748748

749749
KIND = 'KIND'
750750
ID = 1234
@@ -766,7 +766,7 @@ def test_key_w_namespace_collision(self):
766766

767767
def test_batch(self):
768768
from google.cloud.datastore import client as MUT
769-
from unit_tests._testing import _Monkey
769+
from google.cloud._testing import _Monkey
770770

771771
creds = object()
772772
client = self._makeOne(credentials=creds)
@@ -780,7 +780,7 @@ def test_batch(self):
780780

781781
def test_transaction_defaults(self):
782782
from google.cloud.datastore import client as MUT
783-
from unit_tests._testing import _Monkey
783+
from google.cloud._testing import _Monkey
784784

785785
creds = object()
786786
client = self._makeOne(credentials=creds)
@@ -812,7 +812,7 @@ def test_query_w_project(self):
812812

813813
def test_query_w_defaults(self):
814814
from google.cloud.datastore import client as MUT
815-
from unit_tests._testing import _Monkey
815+
from google.cloud._testing import _Monkey
816816

817817
creds = object()
818818
client = self._makeOne(credentials=creds)
@@ -830,7 +830,7 @@ def test_query_w_defaults(self):
830830

831831
def test_query_explicit(self):
832832
from google.cloud.datastore import client as MUT
833-
from unit_tests._testing import _Monkey
833+
from google.cloud._testing import _Monkey
834834

835835
KIND = 'KIND'
836836
NAMESPACE = 'NAMESPACE'
@@ -870,7 +870,7 @@ def test_query_explicit(self):
870870

871871
def test_query_w_namespace(self):
872872
from google.cloud.datastore import client as MUT
873-
from unit_tests._testing import _Monkey
873+
from google.cloud._testing import _Monkey
874874

875875
KIND = 'KIND'
876876
NAMESPACE = object()
@@ -892,7 +892,7 @@ def test_query_w_namespace(self):
892892

893893
def test_query_w_namespace_collision(self):
894894
from google.cloud.datastore import client as MUT
895-
from unit_tests._testing import _Monkey
895+
from google.cloud._testing import _Monkey
896896

897897
KIND = 'KIND'
898898
NAMESPACE1 = object()

unit_tests/datastore/test_connection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _getTargetClass(self):
113113
return _DatastoreAPIOverGRPC
114114

115115
def _makeOne(self, stub, connection=None, secure=True, mock_args=None):
116-
from unit_tests._testing import _Monkey
116+
from google.cloud._testing import _Monkey
117117
from google.cloud.datastore import connection as MUT
118118

119119
if connection is None:
@@ -316,7 +316,7 @@ def _make_query_pb(self, kind):
316316
return pb
317317

318318
def _makeOne(self, credentials=None, http=None, use_grpc=False):
319-
from unit_tests._testing import _Monkey
319+
from google.cloud._testing import _Monkey
320320
from google.cloud.datastore import connection as MUT
321321
with _Monkey(MUT, _USE_GRPC=use_grpc):
322322
return self._getTargetClass()(credentials=credentials, http=http)
@@ -336,7 +336,7 @@ def test_default_url(self):
336336

337337
def test_custom_url_from_env(self):
338338
import os
339-
from unit_tests._testing import _Monkey
339+
from google.cloud._testing import _Monkey
340340
from google.cloud.connection import API_BASE_URL
341341
from google.cloud.environment_vars import GCD_HOST
342342

@@ -354,7 +354,7 @@ def test_ctor_defaults(self):
354354
self.assertIsNone(conn.credentials)
355355

356356
def test_ctor_without_grpc(self):
357-
from unit_tests._testing import _Monkey
357+
from google.cloud._testing import _Monkey
358358
from google.cloud.datastore import connection as MUT
359359

360360
connections = []
@@ -372,7 +372,7 @@ def mock_api(connection):
372372
self.assertEqual(connections, [conn])
373373

374374
def test_ctor_with_grpc(self):
375-
from unit_tests._testing import _Monkey
375+
from google.cloud._testing import _Monkey
376376
from google.cloud.datastore import connection as MUT
377377

378378
api_args = []
@@ -866,7 +866,7 @@ def test_begin_transaction(self):
866866
request.ParseFromString(cw['body'])
867867

868868
def test_commit_wo_transaction(self):
869-
from unit_tests._testing import _Monkey
869+
from google.cloud._testing import _Monkey
870870
from google.cloud.datastore._generated import datastore_pb2
871871
from google.cloud.datastore import connection as MUT
872872
from google.cloud.datastore.helpers import _new_value_pb
@@ -912,7 +912,7 @@ def mock_parse(response):
912912
self.assertEqual(_parsed, [rsp_pb])
913913

914914
def test_commit_w_transaction(self):
915-
from unit_tests._testing import _Monkey
915+
from google.cloud._testing import _Monkey
916916
from google.cloud.datastore._generated import datastore_pb2
917917
from google.cloud.datastore import connection as MUT
918918
from google.cloud.datastore.helpers import _new_value_pb

0 commit comments

Comments
 (0)