From 946021f3d6c8213a96ab2053ad253922dae7cdd4 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Thu, 22 Sep 2016 15:13:11 -0700 Subject: [PATCH] Moving test _helpers back into library. This is preparation for subpackage split-up. --- {unit_tests => google/cloud}/_testing.py | 0 unit_tests/bigquery/test_table.py | 10 ++--- unit_tests/bigtable/test_client.py | 24 ++++++------ unit_tests/bigtable/test_row.py | 8 ++-- unit_tests/bigtable/test_table.py | 4 +- unit_tests/datastore/test_client.py | 30 +++++++-------- unit_tests/datastore/test_connection.py | 14 +++---- unit_tests/logging/test__gax.py | 16 ++++---- unit_tests/logging/test_client.py | 12 +++--- unit_tests/monitoring/test_client.py | 2 +- unit_tests/monitoring/test_query.py | 2 +- unit_tests/pubsub/test__gax.py | 22 +++++------ unit_tests/pubsub/test_client.py | 8 ++-- unit_tests/pubsub/test_connection.py | 2 +- unit_tests/pubsub/test_topic.py | 2 +- unit_tests/storage/test__helpers.py | 2 +- unit_tests/storage/test_blob.py | 28 +++++++------- unit_tests/streaming/test_http_wrapper.py | 20 +++++----- unit_tests/streaming/test_transfer.py | 46 +++++++++++------------ unit_tests/streaming/test_util.py | 4 +- unit_tests/test__helpers.py | 36 +++++++++--------- unit_tests/test_client.py | 10 ++--- unit_tests/test_credentials.py | 8 ++-- unit_tests/test_exceptions.py | 2 +- unit_tests/test_operation.py | 8 ++-- 25 files changed, 160 insertions(+), 160 deletions(-) rename {unit_tests => google/cloud}/_testing.py (100%) diff --git a/unit_tests/_testing.py b/google/cloud/_testing.py similarity index 100% rename from unit_tests/_testing.py rename to google/cloud/_testing.py diff --git a/unit_tests/bigquery/test_table.py b/unit_tests/bigquery/test_table.py index 14eef5e403fbd..6dc985d89af9a 100644 --- a/unit_tests/bigquery/test_table.py +++ b/unit_tests/bigquery/test_table.py @@ -1465,7 +1465,7 @@ def test_upload_from_file_multipart_w_400(self): import csv import datetime from six.moves.http_client import BAD_REQUEST - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile from google.cloud._helpers import UTC from google.cloud.exceptions import BadRequest WHEN_TS = 1437767599.006 @@ -1495,7 +1495,7 @@ def _upload_from_file_helper(self, **kw): import datetime from six.moves.http_client import OK from google.cloud._helpers import UTC - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile from google.cloud.bigquery.table import SchemaField WHEN_TS = 1437767599.006 @@ -1604,8 +1604,8 @@ def test_upload_from_file_resumable_with_400(self): from google.cloud.bigquery import table as MUT from google.cloud.exceptions import BadRequest from google.cloud._helpers import UTC - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile WHEN_TS = 1437767599.006 WHEN = datetime.datetime.utcfromtimestamp(WHEN_TS).replace( tzinfo=UTC) @@ -1643,7 +1643,7 @@ def test_upload_from_file_w_explicit_client_resumable(self): from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigquery import table as MUT UPLOAD_PATH = 'https://example.com/upload/test' diff --git a/unit_tests/bigtable/test_client.py b/unit_tests/bigtable/test_client.py index 9cf8129dea290..237011c9807d5 100644 --- a/unit_tests/bigtable/test_client.py +++ b/unit_tests/bigtable/test_client.py @@ -23,7 +23,7 @@ def _callFUT(self, client): return _make_data_stub(client) def test_without_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT credentials = _Credentials() @@ -51,7 +51,7 @@ def mock_make_secure_stub(*args): ]) def test_with_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT emulator_host = object() @@ -83,7 +83,7 @@ def _callFUT(self, client): return _make_instance_stub(client) def test_without_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT credentials = _Credentials() @@ -111,7 +111,7 @@ def mock_make_secure_stub(*args): ]) def test_with_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT emulator_host = object() @@ -143,7 +143,7 @@ def _callFUT(self, client): return _make_operations_stub(client) def test_without_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT credentials = _Credentials() @@ -171,7 +171,7 @@ def mock_make_secure_stub(*args): ]) def test_with_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT emulator_host = object() @@ -203,7 +203,7 @@ def _callFUT(self, client): return _make_table_stub(client) def test_without_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT credentials = _Credentials() @@ -231,7 +231,7 @@ def mock_make_secure_stub(*args): ]) def test_with_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT emulator_host = object() @@ -271,7 +271,7 @@ def _makeOne(self, *args, **kwargs): return self._getTargetClass()(*args, **kwargs) def _makeOneWithMocks(self, *args, **kwargs): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT mock_make_data_stub = _MakeStubMock() @@ -287,7 +287,7 @@ def _makeOneWithMocks(self, *args, **kwargs): def _constructor_test_helper(self, expected_scopes, creds, read_only=False, admin=False, user_agent=None, expected_creds=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT user_agent = user_agent or MUT.DEFAULT_USER_AGENT @@ -373,7 +373,7 @@ def test_constructor_both_admin_and_read_only(self): read_only=True) def test_constructor_implicit_credentials(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT creds = _Credentials() @@ -392,7 +392,7 @@ def test_constructor_credentials_wo_create_scoped(self): self._constructor_test_helper(expected_scopes, creds) def _copy_test_helper(self, read_only=False, admin=False): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import client as MUT credentials = _Credentials('value') diff --git a/unit_tests/bigtable/test_row.py b/unit_tests/bigtable/test_row.py index 8faf9e58f0f57..0a495bbbe4335 100644 --- a/unit_tests/bigtable/test_row.py +++ b/unit_tests/bigtable/test_row.py @@ -343,7 +343,7 @@ def test_commit(self): self.assertEqual(row._pb_mutations, []) def test_commit_too_many_mutations(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import row as MUT row_key = b'row_key' @@ -481,7 +481,7 @@ def test_commit(self): self.assertEqual(row._false_pb_mutations, []) def test_commit_too_many_mutations(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import row as MUT row_key = b'row_key' @@ -572,7 +572,7 @@ def test_increment_cell_value(self): self.assertEqual(row._rule_pb_list, [expected_pb]) def test_commit(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from unit_tests.bigtable._testing import _FakeStub from google.cloud.bigtable import row as MUT @@ -646,7 +646,7 @@ def test_commit_no_rules(self): self.assertEqual(stub.method_calls, []) def test_commit_too_many_mutations(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.bigtable import row as MUT row_key = b'row_key' diff --git a/unit_tests/bigtable/test_table.py b/unit_tests/bigtable/test_table.py index eff1841e075ea..113cfa0bbd64f 100644 --- a/unit_tests/bigtable/test_table.py +++ b/unit_tests/bigtable/test_table.py @@ -267,7 +267,7 @@ def test_delete(self): )]) def _read_row_helper(self, chunks, expected_result): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from unit_tests.bigtable._testing import _FakeStub from google.cloud.bigtable import table as MUT @@ -347,7 +347,7 @@ def test_read_row_still_partial(self): self._read_row_helper(chunks, None) def test_read_rows(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from unit_tests.bigtable._testing import _FakeStub from google.cloud.bigtable.row_data import PartialRowsData from google.cloud.bigtable import table as MUT diff --git a/unit_tests/datastore/test_client.py b/unit_tests/datastore/test_client.py index f03187805f5c9..79dd7b6b8b055 100644 --- a/unit_tests/datastore/test_client.py +++ b/unit_tests/datastore/test_client.py @@ -39,7 +39,7 @@ def _callFUT(self): def test_no_value(self): import os - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey environ = {} with _Monkey(os, getenv=environ.get): @@ -48,7 +48,7 @@ def test_no_value(self): def test_value_set(self): import os - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore.client import GCD_DATASET MOCK_PROJECT = object() @@ -67,7 +67,7 @@ def _callFUT(self, project=None): def _determine_default_helper(self, gcd=None, fallback=None, project_called=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import client _callers = [] @@ -140,7 +140,7 @@ def _makeOne(self, project=PROJECT, namespace=None, http=http) def test_ctor_w_project_no_environ(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import client as _MUT # Some environments (e.g. AppVeyor CI) run in GCE, so @@ -149,7 +149,7 @@ def test_ctor_w_project_no_environ(self): self.assertRaises(EnvironmentError, self._makeOne, None) def test_ctor_w_implicit_inputs(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import client as _MUT from google.cloud import client as _base_client @@ -494,7 +494,7 @@ def test_get_multi_hit_multiple_keys_different_project(self): client.get_multi([key1, key2]) def test_get_multi_max_loops(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import client as _MUT from google.cloud.datastore.key import Key @@ -702,7 +702,7 @@ def test_key_w_project(self): def test_key_wo_project(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -723,7 +723,7 @@ def test_key_wo_project(self): def test_key_w_namespace(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -744,7 +744,7 @@ def test_key_w_namespace(self): def test_key_w_namespace_collision(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -766,7 +766,7 @@ def test_key_w_namespace_collision(self): def test_batch(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -780,7 +780,7 @@ def test_batch(self): def test_transaction_defaults(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -812,7 +812,7 @@ def test_query_w_project(self): def test_query_w_defaults(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -830,7 +830,7 @@ def test_query_w_defaults(self): def test_query_explicit(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' NAMESPACE = 'NAMESPACE' @@ -870,7 +870,7 @@ def test_query_explicit(self): def test_query_w_namespace(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' NAMESPACE = object() @@ -892,7 +892,7 @@ def test_query_w_namespace(self): def test_query_w_namespace_collision(self): from google.cloud.datastore import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey KIND = 'KIND' NAMESPACE1 = object() diff --git a/unit_tests/datastore/test_connection.py b/unit_tests/datastore/test_connection.py index a4b55cf3ac510..f1030a61c9485 100644 --- a/unit_tests/datastore/test_connection.py +++ b/unit_tests/datastore/test_connection.py @@ -113,7 +113,7 @@ def _getTargetClass(self): return _DatastoreAPIOverGRPC def _makeOne(self, stub, connection=None, secure=True, mock_args=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import connection as MUT if connection is None: @@ -316,7 +316,7 @@ def _make_query_pb(self, kind): return pb def _makeOne(self, credentials=None, http=None, use_grpc=False): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import connection as MUT with _Monkey(MUT, _USE_GRPC=use_grpc): return self._getTargetClass()(credentials=credentials, http=http) @@ -336,7 +336,7 @@ def test_default_url(self): def test_custom_url_from_env(self): import os - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.connection import API_BASE_URL from google.cloud.environment_vars import GCD_HOST @@ -354,7 +354,7 @@ def test_ctor_defaults(self): self.assertIsNone(conn.credentials) def test_ctor_without_grpc(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import connection as MUT connections = [] @@ -372,7 +372,7 @@ def mock_api(connection): self.assertEqual(connections, [conn]) def test_ctor_with_grpc(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore import connection as MUT api_args = [] @@ -866,7 +866,7 @@ def test_begin_transaction(self): request.ParseFromString(cw['body']) def test_commit_wo_transaction(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore._generated import datastore_pb2 from google.cloud.datastore import connection as MUT from google.cloud.datastore.helpers import _new_value_pb @@ -912,7 +912,7 @@ def mock_parse(response): self.assertEqual(_parsed, [rsp_pb]) def test_commit_w_transaction(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.datastore._generated import datastore_pb2 from google.cloud.datastore import connection as MUT from google.cloud.datastore.helpers import _new_value_pb diff --git a/unit_tests/logging/test__gax.py b/unit_tests/logging/test__gax.py index 7fc03b949152e..6b0396c5d4219 100644 --- a/unit_tests/logging/test__gax.py +++ b/unit_tests/logging/test__gax.py @@ -24,7 +24,7 @@ else: _HAVE_GAX = True -from unit_tests._testing import _GAXBaseAPI +from google.cloud._testing import _GAXBaseAPI class _Base(object): @@ -52,7 +52,7 @@ def test_ctor(self): def test_list_entries_no_paging(self): from google.gax import INITIAL_PAGE from google.cloud.logging import DESCENDING - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' TEXT = 'TEXT' @@ -82,7 +82,7 @@ def test_list_entries_no_paging(self): def test_list_entries_with_paging(self): from google.protobuf.struct_pb2 import Value - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' @@ -117,7 +117,7 @@ def test_list_entries_with_paging(self): def test_list_entries_with_extra_properties(self): from datetime import datetime from google.logging.type.log_severity_pb2 import WARNING - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator from google.cloud._helpers import UTC from google.cloud._helpers import _datetime_to_rfc3339 from google.cloud._helpers import _datetime_to_pb_timestamp @@ -454,7 +454,7 @@ def test_ctor(self): def test_list_sinks_no_paging(self): from google.gax import INITIAL_PAGE - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' SINKS = [{ 'name': self.SINK_PATH, @@ -478,7 +478,7 @@ def test_list_sinks_no_paging(self): self.assertEqual(options.page_token, INITIAL_PAGE) def test_list_sinks_w_paging(self): - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' PAGE_SIZE = 42 SINKS = [{ @@ -658,7 +658,7 @@ def test_ctor(self): def test_list_metrics_no_paging(self): from google.gax import INITIAL_PAGE - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' METRICS = [{ 'name': self.METRIC_PATH, @@ -682,7 +682,7 @@ def test_list_metrics_no_paging(self): self.assertEqual(options.page_token, INITIAL_PAGE) def test_list_metrics_w_paging(self): - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' PAGE_SIZE = 42 METRICS = [{ diff --git a/unit_tests/logging/test_client.py b/unit_tests/logging/test_client.py index 23c41b362a426..114f5f635c454 100644 --- a/unit_tests/logging/test_client.py +++ b/unit_tests/logging/test_client.py @@ -41,7 +41,7 @@ def test_ctor(self): def test_logging_api_wo_gax(self): from google.cloud.logging.connection import _LoggingAPI from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey client = self._makeOne(self.PROJECT, credentials=_Credentials()) conn = client.connection = object() @@ -56,7 +56,7 @@ def test_logging_api_wo_gax(self): def test_logging_api_w_gax(self): from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey wrapped = object() _called_with = [] @@ -88,7 +88,7 @@ def __init__(self, _wrapped): def test_sinks_api_wo_gax(self): from google.cloud.logging.connection import _SinksAPI from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey client = self._makeOne(self.PROJECT, credentials=_Credentials()) conn = client.connection = object() @@ -103,7 +103,7 @@ def test_sinks_api_wo_gax(self): def test_sinks_api_w_gax(self): from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey wrapped = object() _called_with = [] @@ -135,7 +135,7 @@ def __init__(self, _wrapped): def test_metrics_api_wo_gax(self): from google.cloud.logging.connection import _MetricsAPI from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey client = self._makeOne(self.PROJECT, credentials=_Credentials()) conn = client.connection = object() @@ -150,7 +150,7 @@ def test_metrics_api_wo_gax(self): def test_metrics_api_w_gax(self): from google.cloud.logging import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey wrapped = object() _called_with = [] diff --git a/unit_tests/monitoring/test_client.py b/unit_tests/monitoring/test_client.py index 7563c2408cf39..b95d1e621a183 100644 --- a/unit_tests/monitoring/test_client.py +++ b/unit_tests/monitoring/test_client.py @@ -184,7 +184,7 @@ def test_resource_factory(self): def test_timeseries_factory_gauge(self): import datetime - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey import google.cloud.monitoring.client from google.cloud._helpers import _datetime_to_rfc3339 METRIC_TYPE = 'custom.googleapis.com/my_metric' diff --git a/unit_tests/monitoring/test_query.py b/unit_tests/monitoring/test_query.py index 065b02c3a51c2..80c809a1f6ac6 100644 --- a/unit_tests/monitoring/test_query.py +++ b/unit_tests/monitoring/test_query.py @@ -126,7 +126,7 @@ def test_constructor_maximal(self): def test_constructor_default_end_time(self): import datetime - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.monitoring import query as MUT MINUTES = 5 diff --git a/unit_tests/pubsub/test__gax.py b/unit_tests/pubsub/test__gax.py index 6ffd86a0a858d..46d05a23d5833 100644 --- a/unit_tests/pubsub/test__gax.py +++ b/unit_tests/pubsub/test__gax.py @@ -24,7 +24,7 @@ else: _HAVE_GAX = True -from unit_tests._testing import _GAXBaseAPI +from google.cloud._testing import _GAXBaseAPI class _Base(object): @@ -55,7 +55,7 @@ def test_ctor(self): def test_list_topics_no_paging(self): from google.gax import INITIAL_PAGE - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator TOKEN = 'TOKEN' response = _GAXPageIterator([_TopicPB(self.TOPIC_PATH)], TOKEN) gax_api = _GAXPublisherAPI(_list_topics_response=response) @@ -75,7 +75,7 @@ def test_list_topics_no_paging(self): self.assertIs(options.page_token, INITIAL_PAGE) def test_list_topics_with_paging(self): - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' @@ -264,7 +264,7 @@ def test_topic_publish_error(self): def test_topic_list_subscriptions_no_paging(self): from google.gax import INITIAL_PAGE - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator response = _GAXPageIterator([ {'name': self.SUB_PATH, 'topic': self.TOPIC_PATH}], None) gax_api = _GAXPublisherAPI(_list_topic_subscriptions_response=response) @@ -287,7 +287,7 @@ def test_topic_list_subscriptions_no_paging(self): self.assertIs(options.page_token, INITIAL_PAGE) def test_topic_list_subscriptions_with_paging(self): - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' @@ -359,7 +359,7 @@ def test_ctor(self): def test_list_subscriptions_no_paging(self): from google.gax import INITIAL_PAGE - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator response = _GAXPageIterator([_SubscriptionPB( self.SUB_PATH, self.TOPIC_PATH, self.PUSH_ENDPOINT, 0)], None) gax_api = _GAXSubscriberAPI(_list_subscriptions_response=response) @@ -383,7 +383,7 @@ def test_list_subscriptions_no_paging(self): self.assertIs(options.page_token, INITIAL_PAGE) def test_list_subscriptions_with_paging(self): - from unit_tests._testing import _GAXPageIterator + from google.cloud._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' @@ -757,7 +757,7 @@ def _callFUT(self, connection): return make_gax_publisher_api(connection) def test_live_api(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.pubsub import _gax as MUT channels = [] @@ -775,7 +775,7 @@ def mock_publisher_api(channel): self.assertEqual(channels, [None]) def test_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.pubsub import _gax as MUT channels = [] @@ -810,7 +810,7 @@ def _callFUT(self, connection): return make_gax_subscriber_api(connection) def test_live_api(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.pubsub import _gax as MUT channels = [] @@ -828,7 +828,7 @@ def mock_subscriber_api(channel): self.assertEqual(channels, [None]) def test_emulator(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.pubsub import _gax as MUT channels = [] diff --git a/unit_tests/pubsub/test_client.py b/unit_tests/pubsub/test_client.py index d6cbf59b019ee..b1929be76df3f 100644 --- a/unit_tests/pubsub/test_client.py +++ b/unit_tests/pubsub/test_client.py @@ -32,7 +32,7 @@ def _makeOne(self, *args, **kw): def test_publisher_api_wo_gax(self): from google.cloud.pubsub.connection import _PublisherAPI from google.cloud.pubsub import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey creds = _Credentials() client = self._makeOne(project=self.PROJECT, credentials=creds) conn = client.connection = object() @@ -48,7 +48,7 @@ def test_publisher_api_wo_gax(self): def test_publisher_api_w_gax(self): from google.cloud.pubsub import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey wrapped = object() _called_with = [] @@ -82,7 +82,7 @@ def __init__(self, _wrapped): def test_subscriber_api_wo_gax(self): from google.cloud.pubsub.connection import _SubscriberAPI from google.cloud.pubsub import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey creds = _Credentials() client = self._makeOne(project=self.PROJECT, credentials=creds) conn = client.connection = object() @@ -98,7 +98,7 @@ def test_subscriber_api_wo_gax(self): def test_subscriber_api_w_gax(self): from google.cloud.pubsub import client as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey wrapped = object() _called_with = [] diff --git a/unit_tests/pubsub/test_connection.py b/unit_tests/pubsub/test_connection.py index d036d82d0b555..9e14e1e0d5287 100644 --- a/unit_tests/pubsub/test_connection.py +++ b/unit_tests/pubsub/test_connection.py @@ -42,7 +42,7 @@ def test_default_url(self): def test_custom_url_from_env(self): import os - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.environment_vars import PUBSUB_EMULATOR HOST = 'localhost:8187' diff --git a/unit_tests/pubsub/test_topic.py b/unit_tests/pubsub/test_topic.py index 26a28945b697d..58e819e187b7a 100644 --- a/unit_tests/pubsub/test_topic.py +++ b/unit_tests/pubsub/test_topic.py @@ -140,7 +140,7 @@ def test_publish_single_bytes_wo_attrs_w_add_timestamp_alt_client(self): import datetime from google.cloud.pubsub import topic as MUT from google.cloud._helpers import _RFC3339_MICROS - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey NOW = datetime.datetime.utcnow() def _utcnow(): diff --git a/unit_tests/storage/test__helpers.py b/unit_tests/storage/test__helpers.py index 82a030f2cae46..f80a7207a7d5a 100644 --- a/unit_tests/storage/test__helpers.py +++ b/unit_tests/storage/test__helpers.py @@ -139,7 +139,7 @@ def test_it(self): self.assertEqual(SIGNED_CONTENT, b'kBiQqOnIz21aGlQrIp/r/w==') def test_it_with_stubs(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.storage import _helpers as MUT class _Buffer(object): diff --git a/unit_tests/storage/test_blob.py b/unit_tests/storage/test_blob.py index f07ec656d85d8..74c2be28e9829 100644 --- a/unit_tests/storage/test_blob.py +++ b/unit_tests/storage/test_blob.py @@ -118,7 +118,7 @@ def test_public_url_w_slash_in_name(self): 'https://storage.googleapis.com/name/parent%2Fchild') def _basic_generate_signed_url_helper(self, credentials=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.storage import blob as MUT BLOB_NAME = 'blob-name' @@ -157,7 +157,7 @@ def test_generate_signed_url_w_default_method(self): self._basic_generate_signed_url_helper() def test_generate_signed_url_w_content_type(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.storage import blob as MUT BLOB_NAME = 'blob-name' @@ -195,7 +195,7 @@ def test_generate_signed_url_w_credentials(self): self._basic_generate_signed_url_helper(credentials=credentials) def test_generate_signed_url_w_slash_in_name(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.storage import blob as MUT BLOB_NAME = 'parent/child' @@ -226,7 +226,7 @@ def test_generate_signed_url_w_slash_in_name(self): self.assertEqual(SIGNER._signed, [(EXPECTED_ARGS, EXPECTED_KWARGS)]) def test_generate_signed_url_w_method_arg(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.storage import blob as MUT BLOB_NAME = 'blob-name' @@ -353,7 +353,7 @@ def test_download_to_filename(self): import time from six.moves.http_client import OK from six.moves.http_client import PARTIAL_CONTENT - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile BLOB_NAME = 'blob-name' chunk1_response = {'status': PARTIAL_CONTENT, @@ -388,7 +388,7 @@ def test_download_to_filename_w_key(self): import time from six.moves.http_client import OK from six.moves.http_client import PARTIAL_CONTENT - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile BLOB_NAME = 'blob-name' KEY = 'aa426195405adee2c8081bb9e7e74b19' @@ -468,7 +468,7 @@ def _upload_from_file_simple_test_helper(self, properties=None, from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile BLOB_NAME = 'blob-name' DATA = b'ABCDEF' @@ -641,8 +641,8 @@ def test_upload_from_file_resumable(self): from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile from google.cloud.streaming import http_wrapper from google.cloud.streaming import transfer @@ -725,8 +725,8 @@ def test_upload_from_file_resumable_w_error(self): from six.moves.http_client import NOT_FOUND from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile from google.cloud.streaming import transfer from google.cloud.streaming.exceptions import HttpError @@ -779,7 +779,7 @@ def test_upload_from_file_w_slash_in_name(self): from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile from google.cloud.streaming import http_wrapper BLOB_NAME = 'parent/child' @@ -829,7 +829,7 @@ def test_upload_from_filename_w_key(self): from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile from google.cloud.streaming import http_wrapper BLOB_NAME = 'blob-name' @@ -888,7 +888,7 @@ def _upload_from_filename_test_helper(self, properties=None, from six.moves.http_client import OK from six.moves.urllib.parse import parse_qsl from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _NamedTemporaryFile from google.cloud.streaming import http_wrapper BLOB_NAME = 'blob-name' diff --git a/unit_tests/streaming/test_http_wrapper.py b/unit_tests/streaming/test_http_wrapper.py index d8506fb8a6e16..8aad20cfb2f10 100644 --- a/unit_tests/streaming/test_http_wrapper.py +++ b/unit_tests/streaming/test_http_wrapper.py @@ -25,7 +25,7 @@ def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_wo_loggable_body_wo_http(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT request = _Request() @@ -36,7 +36,7 @@ def test_wo_loggable_body_wo_http(self): self.assertEqual(_httplib2.debuglevel, 0) def test_w_loggable_body_wo_http(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT request = _Request(loggable_body=object()) @@ -48,7 +48,7 @@ def test_w_loggable_body_wo_http(self): self.assertEqual(_httplib2.debuglevel, 0) def test_w_loggable_body_w_http(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT class _Connection(object): @@ -284,7 +284,7 @@ def _verify_requested(self, http, request, self.assertEqual(kw['connection_type'], connection_type) def test_defaults_wo_connections(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -304,7 +304,7 @@ def test_defaults_wo_connections(self): self._verify_requested(_http, _request) def test_w_http_connections_miss(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -326,7 +326,7 @@ def test_w_http_connections_miss(self): self._verify_requested(_http, _request) def test_w_http_connections_hit(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -348,7 +348,7 @@ def test_w_http_connections_hit(self): self._verify_requested(_http, _request, connection_type=CONN_TYPE) def test_w_request_returning_None(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT from google.cloud.streaming.exceptions import RequestError INFO = None @@ -372,7 +372,7 @@ def _callFUT(self, *args, **kw): def test_wo_exception(self): from google.cloud.streaming import http_wrapper as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey HTTP, REQUEST, RESPONSE = object(), object(), object() _created, _checked = [], [] @@ -393,7 +393,7 @@ def _wo_exception(*args, **kw): def test_w_exceptions_lt_max_retries(self): from google.cloud.streaming.exceptions import RetryAfterError from google.cloud.streaming import http_wrapper as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey HTTP, RESPONSE = object(), object() REQUEST = _Request() @@ -419,7 +419,7 @@ def _wo_exception(*args, **kw): self.assertEqual(_checked, []) # not called by '_wo_exception' def test_w_exceptions_gt_max_retries(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import http_wrapper as MUT HTTP = object() REQUEST = _Request() diff --git a/unit_tests/streaming/test_transfer.py b/unit_tests/streaming/test_transfer.py index 07a989c8a206b..58681585fd5b1 100644 --- a/unit_tests/streaming/test_transfer.py +++ b/unit_tests/streaming/test_transfer.py @@ -289,7 +289,7 @@ def test_initialize_download_wo_autotransfer(self): def test_initialize_download_w_autotransfer_failing(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import HttpError request = _Request() @@ -308,7 +308,7 @@ def test_initialize_download_w_autotransfer_failing(self): def test_initialize_download_w_autotransfer_w_content_location(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT REDIRECT_URL = 'http://example.com/other' request = _Request() @@ -425,7 +425,7 @@ def test__get_chunk_not_initialized(self): def test__get_chunk(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT http = object() download = self._makeOne(_Stream()) @@ -521,7 +521,7 @@ def test_get_range_not_initialized(self): def test_get_range_wo_total_size_complete(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -548,7 +548,7 @@ def test_get_range_wo_total_size_complete(self): def test_get_range_wo_total_size_wo_end(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -577,7 +577,7 @@ def test_get_range_wo_total_size_wo_end(self): def test_get_range_w_total_size_partial(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -606,7 +606,7 @@ def test_get_range_w_total_size_partial(self): def test_get_range_w_empty_chunk(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import TransferRetryError CONTENT = b'ABCDEFGHIJ' @@ -637,7 +637,7 @@ def test_get_range_w_empty_chunk(self): def test_get_range_w_total_size_wo_use_chunks(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -665,7 +665,7 @@ def test_get_range_w_total_size_wo_use_chunks(self): def test_get_range_w_multiple_chunks(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDE' LEN = len(CONTENT) @@ -726,7 +726,7 @@ def test_stream_file_w_initial_response_complete(self): def test_stream_file_w_initial_response_incomplete(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CHUNK_SIZE = 3 CONTENT = b'ABCDEF' @@ -763,7 +763,7 @@ def test_stream_file_w_initial_response_incomplete(self): def test_stream_file_wo_initial_response_wo_total_size(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1138,7 +1138,7 @@ def test_refresh_upload_state_not_initialized(self): def test_refresh_upload_state_w_OK(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1165,7 +1165,7 @@ def test_refresh_upload_state_w_OK(self): def test_refresh_upload_state_w_CREATED(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1193,7 +1193,7 @@ def test_refresh_upload_state_w_CREATED(self): def test_refresh_upload_state_w_RESUME_INCOMPLETE_w_range(self): from google.cloud.streaming import transfer as MUT from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1220,7 +1220,7 @@ def test_refresh_upload_state_w_RESUME_INCOMPLETE_w_range(self): def test_refresh_upload_state_w_RESUME_INCOMPLETE_wo_range(self): from google.cloud.streaming import transfer as MUT from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1244,7 +1244,7 @@ def test_refresh_upload_state_w_RESUME_INCOMPLETE_wo_range(self): def test_refresh_upload_state_w_error(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import HttpError from google.cloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1304,7 +1304,7 @@ def test_initialize_upload_resumable_already_initialized(self): def test_initialize_upload_w_http_resumable_not_initialized_w_error(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import HttpError from google.cloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1320,7 +1320,7 @@ def test_initialize_upload_w_http_resumable_not_initialized_w_error(self): def test_initialize_upload_w_http_wo_auto_transfer_w_OK(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.transfer import RESUMABLE_UPLOAD request = _Request() @@ -1341,7 +1341,7 @@ def test_initialize_upload_w_http_wo_auto_transfer_w_OK(self): def test_initialize_upload_w_granularity_w_auto_transfer_w_OK(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1493,7 +1493,7 @@ def test_stream_file_already_complete_w_seekable_method_false(self): def test_stream_file_incomplete(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE from google.cloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1537,7 +1537,7 @@ def test_stream_file_incomplete(self): self.assertEqual(request_2.body, CONTENT[6:]) def test_stream_file_incomplete_w_transfer_error(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import CommunicationError from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE @@ -1575,7 +1575,7 @@ def test_stream_file_incomplete_w_transfer_error(self): self.assertEqual(request.body, CONTENT[:6]) def test__send_media_request_wo_error(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE CONTENT = b'ABCDEFGHIJ' @@ -1603,7 +1603,7 @@ def test__send_media_request_wo_error(self): def test__send_media_request_w_error(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.streaming import transfer as MUT from google.cloud.streaming.exceptions import HttpError from google.cloud.streaming.http_wrapper import RESUME_INCOMPLETE diff --git a/unit_tests/streaming/test_util.py b/unit_tests/streaming/test_util.py index bd9c832d0fdd9..c760a19556102 100644 --- a/unit_tests/streaming/test_util.py +++ b/unit_tests/streaming/test_util.py @@ -23,13 +23,13 @@ def _callFUT(self, *args, **kw): def test_w_negative_jitter_lt_max_wait(self): import random - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey with _Monkey(random, uniform=lambda lower, upper: lower): self.assertEqual(self._callFUT(1), 1.5) def test_w_positive_jitter_gt_max_wait(self): import random - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey with _Monkey(random, uniform=lambda lower, upper: upper): self.assertEqual(self._callFUT(4), 20) diff --git a/unit_tests/test__helpers.py b/unit_tests/test__helpers.py index bb1594f62af01..4dd512ee97011 100644 --- a/unit_tests/test__helpers.py +++ b/unit_tests/test__helpers.py @@ -131,7 +131,7 @@ def _callFUT(self): return _app_engine_id() def test_no_value(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import _helpers with _Monkey(_helpers, app_identity=None): @@ -139,7 +139,7 @@ def test_no_value(self): self.assertIsNone(dataset_id) def test_value_set(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import _helpers APP_ENGINE_ID = object() @@ -157,8 +157,8 @@ def _callFUT(self): def test_success(self): from google.cloud.environment_vars import CREDENTIALS - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile project_id = 'test-project-id' payload = '{"%s":"%s"}' % ('project_id', project_id) @@ -173,7 +173,7 @@ def test_success(self): self.assertEqual(result, project_id) def test_no_environment_variable_set(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey environ = {} with _Monkey(os, getenv=environ.get): @@ -190,7 +190,7 @@ def _callFUT(self): def test_it(self): from google.cloud import _helpers as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey user_root = 'a' config_file = 'b' @@ -210,7 +210,7 @@ def _callFUT(self): def test_it(self): from google.cloud import _helpers as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey appdata_dir = 'a' environ = {'APPDATA': appdata_dir} @@ -233,8 +233,8 @@ def _callFUT(self): def test_nix(self): from google.cloud import _helpers as MUT - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile project_id = 'test-project-id' with _NamedTemporaryFile() as temp: @@ -256,8 +256,8 @@ def mock_get_path(): def test_windows(self): from google.cloud import _helpers as MUT - from unit_tests._testing import _Monkey - from unit_tests._testing import _NamedTemporaryFile + from google.cloud._testing import _Monkey + from google.cloud._testing import _NamedTemporaryFile project_id = 'test-project-id' with _NamedTemporaryFile() as temp: @@ -279,7 +279,7 @@ def mock_get_path(): def test_gae(self): from google.cloud import _helpers as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey with _Monkey(os, name='not-nt'): with _Monkey(MUT, _USER_ROOT=None): @@ -296,7 +296,7 @@ def _callFUT(self): def _monkeyConnection(self, connection): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey def _connection_factory(host, timeout): connection.host = host @@ -332,7 +332,7 @@ def _callFUT(self): return _get_production_project() def test_no_value(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey environ = {} with _Monkey(os, getenv=environ.get): @@ -340,7 +340,7 @@ def test_no_value(self): self.assertIsNone(project) def test_value_set(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud._helpers import PROJECT MOCK_PROJECT = object() @@ -358,7 +358,7 @@ def _callFUT(self, project=None): def _determine_default_helper(self, prod=None, gae=None, gce=None, file_id=None, srv_id=None, project=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import _helpers _callers = [] @@ -907,7 +907,7 @@ def _callFUT(self, *args, **kwargs): def test_it(self): from six.moves import http_client - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import _helpers as MUT mock_result = object() @@ -988,7 +988,7 @@ def _callFUT(self, *args, **kwargs): return make_insecure_stub(*args, **kwargs) def _helper(self, target, host, port=None): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import _helpers as MUT mock_result = object() diff --git a/unit_tests/test_client.py b/unit_tests/test_client.py index fed78d8c9fbe2..c7e4c6536e1b8 100644 --- a/unit_tests/test_client.py +++ b/unit_tests/test_client.py @@ -45,7 +45,7 @@ def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_ctor_defaults(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import client CREDENTIALS = object() @@ -72,7 +72,7 @@ def test_ctor_explicit(self): self.assertIs(client_obj.connection.http, HTTP) def test_from_service_account_json(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import client KLASS = self._getTargetClass() @@ -91,7 +91,7 @@ def test_from_service_account_json_fail(self): credentials=CREDENTIALS) def test_from_service_account_p12(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import client KLASS = self._getTargetClass() @@ -132,7 +132,7 @@ def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_ctor_defaults(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import client PROJECT = 'PROJECT' @@ -159,7 +159,7 @@ def mock_get_credentials(): [(None, '_determine_default_project'), 'get_credentials']) def test_ctor_missing_project(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import client FUNC_CALLS = [] diff --git a/unit_tests/test_credentials.py b/unit_tests/test_credentials.py index 38b9b614b63ee..9fc10dcca4e81 100644 --- a/unit_tests/test_credentials.py +++ b/unit_tests/test_credentials.py @@ -22,7 +22,7 @@ def _callFUT(self): return credentials.get_credentials() def test_it(self): - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import credentials as MUT client = _Client() @@ -44,7 +44,7 @@ def _generate_helper(self, response_type=None, response_disposition=None, import base64 from six.moves.urllib.parse import parse_qs from six.moves.urllib.parse import urlsplit - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import credentials as MUT ENDPOINT = 'http://api.example.com' @@ -196,7 +196,7 @@ class CET(_UTC): def test_w_timedelta_seconds(self): import datetime - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import credentials as MUT dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0) @@ -210,7 +210,7 @@ def test_w_timedelta_seconds(self): def test_w_timedelta_days(self): import datetime - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud import credentials as MUT dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0) diff --git a/unit_tests/test_exceptions.py b/unit_tests/test_exceptions.py index 362881a44124a..56d8581be036a 100644 --- a/unit_tests/test_exceptions.py +++ b/unit_tests/test_exceptions.py @@ -85,7 +85,7 @@ def test_hit_w_content_as_unicode(self): def test_hit_w_content_as_unicode_as_py3(self): import six - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey from google.cloud.exceptions import NotFound error_message = u'That is not found.' expected = u'404 %s' % (error_message,) diff --git a/unit_tests/test_operation.py b/unit_tests/test_operation.py index bfe5aeafee17b..234b5d93c7494 100644 --- a/unit_tests/test_operation.py +++ b/unit_tests/test_operation.py @@ -52,7 +52,7 @@ def _callFUT(self, type_url, klass): def test_simple(self): from google.cloud import operation as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey TYPE_URI = 'testing.google-cloud-python.com/testing' klass = object() type_url_map = {} @@ -64,7 +64,7 @@ def test_simple(self): def test_w_same_class(self): from google.cloud import operation as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey TYPE_URI = 'testing.google-cloud-python.com/testing' klass = object() type_url_map = {TYPE_URI: klass} @@ -76,7 +76,7 @@ def test_w_same_class(self): def test_w_conflict(self): from google.cloud import operation as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey TYPE_URI = 'testing.google-cloud-python.com/testing' klass, other = object(), object() type_url_map = {TYPE_URI: other} @@ -158,7 +158,7 @@ def test_from_pb_w_metadata_and_kwargs(self): from google.protobuf.any_pb2 import Any from google.protobuf.struct_pb2 import Struct, Value from google.cloud import operation as MUT - from unit_tests._testing import _Monkey + from google.cloud._testing import _Monkey TYPE_URI = 'type.googleapis.com/%s' % (Struct.DESCRIPTOR.full_name,) type_url_map = {TYPE_URI: Struct}