Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ covercmd =
--exclude-dir=system_tests \
--with-coverage \
--cover-package=gcloud \
--cover-package=unit_tests \
--cover-erase \
--cover-tests \
--cover-branches \
Expand Down
13 changes: 13 additions & 0 deletions unit_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
File renamed without changes.
13 changes: 13 additions & 0 deletions unit_tests/bigquery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ def _upload_from_file_helper(self, **kw):
import datetime
from six.moves.http_client import OK
from gcloud._helpers import UTC
from gcloud._testing import _NamedTemporaryFile
from unit_tests._testing import _NamedTemporaryFile
from gcloud.bigquery.table import SchemaField

WHEN_TS = 1437767599.006
Expand Down Expand Up @@ -1515,7 +1515,6 @@ def test_upload_from_file_w_bound_client_multipart(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit
from gcloud._helpers import _to_bytes
from gcloud.streaming.test_transfer import _email_chunk_parser

requested, PATH, BODY = self._upload_from_file_helper()
parse_chunk = _email_chunk_parser()
Expand Down Expand Up @@ -1571,7 +1570,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 gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigquery import table as MUT

UPLOAD_PATH = 'https://example.com/upload/test'
Expand Down Expand Up @@ -1856,3 +1855,15 @@ def build_api_url(self, path, query_params=None,
qs = urlencode(query_params or {})
scheme, netloc, _, _, _ = urlsplit(api_base_url)
return urlunsplit((scheme, netloc, path, qs, ''))


def _email_chunk_parser():
import six
if six.PY3: # pragma: NO COVER Python3
from email.parser import BytesParser
parser = BytesParser()
return parser.parsebytes
else:
from email.parser import Parser
parser = Parser()
return parser.parsestr
13 changes: 13 additions & 0 deletions unit_tests/bigtable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
File renamed without changes.
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_it(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

credentials = _Credentials()
Expand Down Expand Up @@ -59,7 +59,7 @@ def _callFUT(self, client):
return _make_instance_stub(client)

def test_it(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

credentials = _Credentials()
Expand Down Expand Up @@ -95,7 +95,7 @@ def _callFUT(self, client):
return _make_operations_stub(client)

def test_it(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

credentials = _Credentials()
Expand Down Expand Up @@ -131,7 +131,7 @@ def _callFUT(self, client):
return _make_table_stub(client)

def test_it(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

credentials = _Credentials()
Expand Down Expand Up @@ -175,7 +175,7 @@ def _makeOne(self, *args, **kwargs):
return self._getTargetClass()(*args, **kwargs)

def _makeOneWithMocks(self, *args, **kwargs):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

mock_make_data_stub = _MakeStubMock()
Expand All @@ -191,7 +191,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 gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

user_agent = user_agent or MUT.DEFAULT_USER_AGENT
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_constructor_both_admin_and_read_only(self):
read_only=True)

def test_constructor_implicit_credentials(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

creds = _Credentials()
Expand All @@ -296,7 +296,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 gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import client as MUT

credentials = _Credentials('value')
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_list_instances(self):
instance_pb2 as data_v2_pb2)
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

LOCATION = 'projects/' + self.PROJECT + '/locations/locname'
FAILED_LOCATION = 'FAILED'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test___ne__(self):
self.assertNotEqual(cluster1, cluster2)

def test_reload(self):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.bigtable.cluster import DEFAULT_SERVE_NODES

SERVE_NODES = 31
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_create(self):
from gcloud.operation import Operation
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

SERVE_NODES = 4
client = _Client(self.PROJECT)
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_update(self):
instance_pb2 as data_v2_pb2)
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.bigtable.cluster import _UPDATE_CLUSTER_METADATA_URL

NOW = datetime.datetime.utcnow()
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_update(self):

def test_delete(self):
from google.protobuf import empty_pb2
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

client = _Client(self.PROJECT)
instance = _Instance(self.INSTANCE_ID, client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def test_to_pb_with_rule(self):
def _create_test_helper(self, gc_rule=None):
from gcloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

project_id = 'project-id'
zone = 'zone'
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_create_with_gc_rule(self):
self._create_test_helper(gc_rule=gc_rule)

def _update_test_helper(self, gc_rule=None):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)

Expand Down Expand Up @@ -524,7 +524,7 @@ def test_delete(self):
from google.protobuf import empty_pb2
from gcloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

project_id = 'project-id'
zone = 'zone'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_reload(self):
instance_pb2 as data_v2_pb2)
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

client = _Client(self.PROJECT)
instance = self._makeOne(self.INSTANCE_ID, client, self.LOCATION_ID)
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_create(self):
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud._helpers import _datetime_to_pb_timestamp
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.operation import Operation
from gcloud.bigtable.cluster import DEFAULT_SERVE_NODES
from gcloud.bigtable.instance import _CREATE_INSTANCE_METADATA_URL
Expand Down Expand Up @@ -285,7 +285,7 @@ def test_create_w_explicit_serve_nodes(self):
from google.longrunning import operations_pb2
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.operation import Operation

SERVE_NODES = 5
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_create_w_explicit_serve_nodes(self):
def test_update(self):
from gcloud.bigtable._generated import (
instance_pb2 as data_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

client = _Client(self.PROJECT)
instance = self._makeOne(self.INSTANCE_ID, client, self.LOCATION_ID,
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_delete(self):
from google.protobuf import empty_pb2
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

client = _Client(self.PROJECT)
instance = self._makeOne(self.INSTANCE_ID, client, self.LOCATION_ID)
Expand Down Expand Up @@ -392,7 +392,7 @@ def test_list_clusters(self):
instance_pb2 as instance_v2_pb2)
from gcloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

FAILED_LOCATION = 'FAILED'
FAILED_LOCATIONS = [FAILED_LOCATION]
Expand Down Expand Up @@ -449,7 +449,7 @@ def _list_tables_helper(self, table_name=None):
table_pb2 as table_data_v2_pb2)
from gcloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_messages_v1_pb2)
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

client = _Client(self.PROJECT)
instance = self._makeOne(self.INSTANCE_ID, client, self.LOCATION_ID)
Expand Down
20 changes: 10 additions & 10 deletions gcloud/bigtable/test_row.py → unit_tests/bigtable/test_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_delete_cells_with_string_columns(self):

def test_commit(self):
from google.protobuf import empty_pb2
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

row_key = b'row_key'
table_name = 'projects/more-stuff'
Expand Down Expand Up @@ -343,7 +343,7 @@ def test_commit(self):
self.assertEqual(row._pb_mutations, [])

def test_commit_too_many_mutations(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import row as MUT

row_key = b'row_key'
Expand All @@ -356,7 +356,7 @@ def test_commit_too_many_mutations(self):
row.commit()

def test_commit_no_mutations(self):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

row_key = b'row_key'
client = _Client()
Expand Down Expand Up @@ -407,7 +407,7 @@ def test__get_mutations(self):
self.assertTrue(false_mutations is row._get_mutations(None))

def test_commit(self):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub
from gcloud.bigtable.row_filters import RowSampleFilter

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 gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import row as MUT

row_key = b'row_key'
Expand All @@ -495,7 +495,7 @@ def test_commit_too_many_mutations(self):
row.commit()

def test_commit_no_mutations(self):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

row_key = b'row_key'
client = _Client()
Expand Down Expand Up @@ -572,8 +572,8 @@ def test_increment_cell_value(self):
self.assertEqual(row._rule_pb_list, [expected_pb])

def test_commit(self):
from gcloud._testing import _Monkey
from gcloud.bigtable._testing import _FakeStub
from unit_tests._testing import _Monkey
from unit_tests.bigtable._testing import _FakeStub
from gcloud.bigtable import row as MUT

row_key = b'row_key'
Expand Down Expand Up @@ -628,7 +628,7 @@ def mock_parse_rmw_row_response(row_response):
self.assertEqual(row._rule_pb_list, [])

def test_commit_no_rules(self):
from gcloud.bigtable._testing import _FakeStub
from unit_tests.bigtable._testing import _FakeStub

row_key = b'row_key'
client = _Client()
Expand All @@ -646,7 +646,7 @@ def test_commit_no_rules(self):
self.assertEqual(stub.method_calls, [])

def test_commit_too_many_mutations(self):
from gcloud._testing import _Monkey
from unit_tests._testing import _Monkey
from gcloud.bigtable import row as MUT

row_key = b'row_key'
Expand Down
File renamed without changes.
Loading