Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving test _helpers back into library. #2394

Merged
merged 1 commit into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
10 changes: 5 additions & 5 deletions unit_tests/bigquery/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down
24 changes: 12 additions & 12 deletions unit_tests/bigtable/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions unit_tests/bigtable/test_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/bigtable/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions unit_tests/datastore/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand All @@ -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 = []
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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'
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
14 changes: 7 additions & 7 deletions unit_tests/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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 = []
Expand All @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading