diff --git a/tox.ini b/tox.ini index b7863d9a31a0..8b00b0bd7d08 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ covercmd = --exclude-dir=system_tests \ --with-coverage \ --cover-package=gcloud \ + --cover-package=unit_tests \ --cover-erase \ --cover-tests \ --cover-branches \ diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/__init__.py @@ -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. diff --git a/gcloud/_testing.py b/unit_tests/_testing.py similarity index 100% rename from gcloud/_testing.py rename to unit_tests/_testing.py diff --git a/unit_tests/bigquery/__init__.py b/unit_tests/bigquery/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/bigquery/__init__.py @@ -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. diff --git a/gcloud/bigquery/test__helpers.py b/unit_tests/bigquery/test__helpers.py similarity index 100% rename from gcloud/bigquery/test__helpers.py rename to unit_tests/bigquery/test__helpers.py diff --git a/gcloud/bigquery/test_client.py b/unit_tests/bigquery/test_client.py similarity index 100% rename from gcloud/bigquery/test_client.py rename to unit_tests/bigquery/test_client.py diff --git a/gcloud/bigquery/test_connection.py b/unit_tests/bigquery/test_connection.py similarity index 100% rename from gcloud/bigquery/test_connection.py rename to unit_tests/bigquery/test_connection.py diff --git a/gcloud/bigquery/test_dataset.py b/unit_tests/bigquery/test_dataset.py similarity index 100% rename from gcloud/bigquery/test_dataset.py rename to unit_tests/bigquery/test_dataset.py diff --git a/gcloud/bigquery/test_job.py b/unit_tests/bigquery/test_job.py similarity index 100% rename from gcloud/bigquery/test_job.py rename to unit_tests/bigquery/test_job.py diff --git a/gcloud/bigquery/test_query.py b/unit_tests/bigquery/test_query.py similarity index 100% rename from gcloud/bigquery/test_query.py rename to unit_tests/bigquery/test_query.py diff --git a/gcloud/bigquery/test_schema.py b/unit_tests/bigquery/test_schema.py similarity index 100% rename from gcloud/bigquery/test_schema.py rename to unit_tests/bigquery/test_schema.py diff --git a/gcloud/bigquery/test_table.py b/unit_tests/bigquery/test_table.py similarity index 99% rename from gcloud/bigquery/test_table.py rename to unit_tests/bigquery/test_table.py index 3590f80b27a5..b5da81f61079 100644 --- a/gcloud/bigquery/test_table.py +++ b/unit_tests/bigquery/test_table.py @@ -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 @@ -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() @@ -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' @@ -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 diff --git a/unit_tests/bigtable/__init__.py b/unit_tests/bigtable/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/bigtable/__init__.py @@ -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. diff --git a/gcloud/bigtable/_testing.py b/unit_tests/bigtable/_testing.py similarity index 100% rename from gcloud/bigtable/_testing.py rename to unit_tests/bigtable/_testing.py diff --git a/gcloud/bigtable/read-rows-acceptance-test.json b/unit_tests/bigtable/read-rows-acceptance-test.json similarity index 100% rename from gcloud/bigtable/read-rows-acceptance-test.json rename to unit_tests/bigtable/read-rows-acceptance-test.json diff --git a/gcloud/bigtable/test_client.py b/unit_tests/bigtable/test_client.py similarity index 97% rename from gcloud/bigtable/test_client.py rename to unit_tests/bigtable/test_client.py index f071f8f1bf61..5d406d412619 100644 --- a/gcloud/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_it(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.bigtable import client as MUT credentials = _Credentials() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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 @@ -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() @@ -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') @@ -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' diff --git a/gcloud/bigtable/test_cluster.py b/unit_tests/bigtable/test_cluster.py similarity index 98% rename from gcloud/bigtable/test_cluster.py rename to unit_tests/bigtable/test_cluster.py index 9ad256159fd0..b253a7f7d461 100644 --- a/gcloud/bigtable/test_cluster.py +++ b/unit_tests/bigtable/test_cluster.py @@ -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 @@ -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) @@ -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() @@ -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) diff --git a/gcloud/bigtable/test_column_family.py b/unit_tests/bigtable/test_column_family.py similarity index 99% rename from gcloud/bigtable/test_column_family.py rename to unit_tests/bigtable/test_column_family.py index 207a3df99cb1..371df1a6c1d8 100644 --- a/gcloud/bigtable/test_column_family.py +++ b/unit_tests/bigtable/test_column_family.py @@ -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' @@ -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) @@ -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' diff --git a/gcloud/bigtable/test_instance.py b/unit_tests/bigtable/test_instance.py similarity index 98% rename from gcloud/bigtable/test_instance.py rename to unit_tests/bigtable/test_instance.py index 0f9fce2ad8c5..54d1ff12d381 100644 --- a/gcloud/bigtable/test_instance.py +++ b/unit_tests/bigtable/test_instance.py @@ -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) @@ -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 @@ -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 @@ -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, @@ -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) @@ -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] @@ -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) diff --git a/gcloud/bigtable/test_row.py b/unit_tests/bigtable/test_row.py similarity index 98% rename from gcloud/bigtable/test_row.py rename to unit_tests/bigtable/test_row.py index 8331a68fcb73..f5d33023da32 100644 --- a/gcloud/bigtable/test_row.py +++ b/unit_tests/bigtable/test_row.py @@ -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' @@ -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' @@ -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() @@ -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' @@ -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' @@ -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() @@ -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' @@ -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() @@ -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' diff --git a/gcloud/bigtable/test_row_data.py b/unit_tests/bigtable/test_row_data.py similarity index 100% rename from gcloud/bigtable/test_row_data.py rename to unit_tests/bigtable/test_row_data.py diff --git a/gcloud/bigtable/test_row_filters.py b/unit_tests/bigtable/test_row_filters.py similarity index 100% rename from gcloud/bigtable/test_row_filters.py rename to unit_tests/bigtable/test_row_filters.py diff --git a/gcloud/bigtable/test_table.py b/unit_tests/bigtable/test_table.py similarity index 97% rename from gcloud/bigtable/test_table.py rename to unit_tests/bigtable/test_table.py index 4d7a25d50d46..dd78fb722d47 100644 --- a/gcloud/bigtable/test_table.py +++ b/unit_tests/bigtable/test_table.py @@ -134,7 +134,7 @@ def test___ne__(self): def _create_test_helper(self, initial_split_keys, column_families=()): from gcloud._helpers import _to_bytes - from gcloud.bigtable._testing import _FakeStub + from unit_tests.bigtable._testing import _FakeStub client = _Client() instance = _Instance(self.INSTANCE_NAME, client=client) @@ -201,7 +201,7 @@ def test_create_with_column_families(self): column_families=column_families) def _list_column_families_helper(self): - from gcloud.bigtable._testing import _FakeStub + from unit_tests.bigtable._testing import _FakeStub client = _Client() instance = _Instance(self.INSTANCE_NAME, client=client) @@ -239,7 +239,7 @@ def test_list_column_families(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() instance = _Instance(self.INSTANCE_NAME, client=client) @@ -267,8 +267,8 @@ def test_delete(self): )]) def _read_row_helper(self, chunks, expected_result): - 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 table as MUT client = _Client() @@ -347,8 +347,8 @@ def test_read_row_still_partial(self): self._read_row_helper(chunks, None) def test_read_rows(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.row_data import PartialRowsData from gcloud.bigtable import table as MUT @@ -398,7 +398,7 @@ def mock_create_row_request(table_name, **kwargs): self.assertEqual(mock_created, [(table.name, created_kwargs)]) def test_sample_row_keys(self): - from gcloud.bigtable._testing import _FakeStub + from unit_tests.bigtable._testing import _FakeStub client = _Client() instance = _Instance(self.INSTANCE_NAME, client=client) diff --git a/unit_tests/datastore/__init__.py b/unit_tests/datastore/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/datastore/__init__.py @@ -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. diff --git a/gcloud/datastore/test_batch.py b/unit_tests/datastore/test_batch.py similarity index 100% rename from gcloud/datastore/test_batch.py rename to unit_tests/datastore/test_batch.py diff --git a/gcloud/datastore/test_client.py b/unit_tests/datastore/test_client.py similarity index 92% rename from gcloud/datastore/test_client.py rename to unit_tests/datastore/test_client.py index a0a082e9de82..a3a7110dddab 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import client as _MUT from gcloud 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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import client as _MUT from gcloud.datastore.key import Key @@ -553,10 +553,6 @@ def test_put_multi_w_single_empty_entity(self): def test_put_multi_no_batch_w_partial_key(self): from gcloud.datastore.helpers import _property_tuples - from gcloud.datastore.test_batch import _Entity - from gcloud.datastore.test_batch import _Key - from gcloud.datastore.test_batch import _KeyPB - from gcloud.datastore.test_batch import _mutated_pb entity = _Entity(foo=u'bar') key = entity.key = _Key(self.PROJECT) @@ -587,9 +583,6 @@ def test_put_multi_no_batch_w_partial_key(self): def test_put_multi_existing_batch_w_completed_key(self): from gcloud.datastore.helpers import _property_tuples - from gcloud.datastore.test_batch import _Entity - from gcloud.datastore.test_batch import _Key - from gcloud.datastore.test_batch import _mutated_pb creds = object() client = self._makeOne(credentials=creds) @@ -633,9 +626,6 @@ def test_delete_multi_no_keys(self): self.assertEqual(len(client.connection._commit_cw), 0) def test_delete_multi_no_batch(self): - from gcloud.datastore.test_batch import _Key - from gcloud.datastore.test_batch import _mutated_pb - key = _Key(self.PROJECT) creds = object() @@ -654,9 +644,6 @@ def test_delete_multi_no_batch(self): self.assertTrue(transaction_id is None) def test_delete_multi_w_existing_batch(self): - from gcloud.datastore.test_batch import _Key - from gcloud.datastore.test_batch import _mutated_pb - creds = object() client = self._makeOne(credentials=creds) key = _Key(self.PROJECT) @@ -670,9 +657,6 @@ def test_delete_multi_w_existing_batch(self): self.assertEqual(len(client.connection._commit_cw), 0) def test_delete_multi_w_existing_transaction(self): - from gcloud.datastore.test_batch import _Key - from gcloud.datastore.test_batch import _mutated_pb - creds = object() client = self._makeOne(credentials=creds) key = _Key(self.PROJECT) @@ -686,8 +670,6 @@ def test_delete_multi_w_existing_transaction(self): self.assertEqual(len(client.connection._commit_cw), 0) def test_allocate_ids_w_partial_key(self): - from gcloud.datastore.test_batch import _Key - NUM_IDS = 2 INCOMPLETE_KEY = _Key(self.PROJECT) @@ -702,8 +684,6 @@ def test_allocate_ids_w_partial_key(self): self.assertEqual([key._id for key in result], list(range(NUM_IDS))) def test_allocate_ids_with_completed_key(self): - from gcloud.datastore.test_batch import _Key - creds = object() client = self._makeOne(credentials=creds) @@ -722,7 +702,7 @@ def test_key_w_project(self): def test_key_wo_project(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -743,7 +723,7 @@ def test_key_wo_project(self): def test_key_w_namespace(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -764,7 +744,7 @@ def test_key_w_namespace(self): def test_key_w_namespace_collision(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' ID = 1234 @@ -786,7 +766,7 @@ def test_key_w_namespace_collision(self): def test_batch(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -800,7 +780,7 @@ def test_batch(self): def test_transaction_defaults(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -832,7 +812,7 @@ def test_query_w_project(self): def test_query_w_defaults(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey creds = object() client = self._makeOne(credentials=creds) @@ -850,7 +830,7 @@ def test_query_w_defaults(self): def test_query_explicit(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' NAMESPACE = 'NAMESPACE' @@ -890,7 +870,7 @@ def test_query_explicit(self): def test_query_w_namespace(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' NAMESPACE = object() @@ -912,7 +892,7 @@ def test_query_w_namespace(self): def test_query_w_namespace_collision(self): from gcloud.datastore import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey KIND = 'KIND' NAMESPACE1 = object() @@ -969,10 +949,9 @@ def commit(self, project, commit_request, transaction_id): return self._index_updates, response def allocate_ids(self, project, key_pbs): - from gcloud.datastore.test_connection import _KeyProto self._alloc_cw.append((project, key_pbs)) num_pbs = len(key_pbs) - return [_KeyProto(i) for i in list(range(num_pbs))] + return [_KeyPB(i) for i in list(range(num_pbs))] class _NoCommitBatch(object): @@ -1004,3 +983,73 @@ def __enter__(self): def __exit__(self, *args): self._client._pop_batch() + + +class _Entity(dict): + key = None + exclude_from_indexes = () + _meanings = {} + + +class _Key(object): + _MARKER = object() + _kind = 'KIND' + _key = 'KEY' + _path = None + _id = 1234 + _stored = None + + def __init__(self, project): + self.project = project + + @property + def is_partial(self): + return self._id is None + + def to_protobuf(self): + from gcloud.datastore._generated import entity_pb2 + key = self._key = entity_pb2.Key() + # Don't assign it, because it will just get ripped out + # key.partition_id.project_id = self.project + + element = key.path.add() + element.kind = self._kind + if self._id is not None: + element.id = self._id + + return key + + def completed_key(self, new_id): + assert self.is_partial + new_key = self.__class__(self.project) + new_key._id = new_id + return new_key + + +class _PathElementPB(object): + + def __init__(self, id_): + self.id = id_ + + +class _KeyPB(object): + + def __init__(self, id_): + self.path = [_PathElementPB(id_)] + + +def _assert_num_mutations(test_case, mutation_pb_list, num_mutations): + test_case.assertEqual(len(mutation_pb_list), num_mutations) + + +def _mutated_pb(test_case, mutation_pb_list, mutation_type): + # Make sure there is only one mutation. + _assert_num_mutations(test_case, mutation_pb_list, 1) + + # We grab the only mutation. + mutated_pb = mutation_pb_list[0] + # Then check if it is the correct type. + test_case.assertEqual(mutated_pb.WhichOneof('operation'), + mutation_type) + + return getattr(mutated_pb, mutation_type) diff --git a/gcloud/datastore/test_connection.py b/unit_tests/datastore/test_connection.py similarity index 98% rename from gcloud/datastore/test_connection.py rename to unit_tests/datastore/test_connection.py index cfa0dc80d906..1067a9357b71 100644 --- a/gcloud/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, mock_args=None): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import connection as MUT if connection is None: @@ -293,7 +293,7 @@ def _make_query_pb(self, kind): def _makeOne(self, credentials=None, http=None, api_base_url=None, have_grpc=False): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import connection as MUT with _Monkey(MUT, _HAVE_GRPC=have_grpc): return self._getTargetClass()(credentials=credentials, http=http, @@ -314,7 +314,7 @@ def test_default_url(self): def test_custom_url_from_env(self): import os - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.connection import API_BASE_URL from gcloud.environment_vars import GCD_HOST @@ -337,7 +337,7 @@ def test_custom_url_from_constructor(self): def test_custom_url_constructor_and_env(self): import os - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.connection import API_BASE_URL from gcloud.environment_vars import GCD_HOST @@ -357,7 +357,7 @@ def test_ctor_defaults(self): self.assertEqual(conn.credentials, None) def test_ctor_without_grpc(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import connection as MUT connections = [] @@ -375,7 +375,7 @@ def mock_api(connection): self.assertEqual(connections, [conn]) def test_ctor_with_grpc(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore import connection as MUT connections = [] @@ -869,7 +869,7 @@ def test_begin_transaction(self): request.ParseFromString(cw['body']) def test_commit_wo_transaction(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore._generated import datastore_pb2 from gcloud.datastore import connection as MUT from gcloud.datastore.helpers import _new_value_pb @@ -915,7 +915,7 @@ def mock_parse(response): self.assertEqual(_parsed, [rsp_pb]) def test_commit_w_transaction(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.datastore._generated import datastore_pb2 from gcloud.datastore import connection as MUT from gcloud.datastore.helpers import _new_value_pb @@ -1091,18 +1091,6 @@ def request(self, **kw): return self._response, self._content -class _PathElementProto(object): - - def __init__(self, _id): - self.id = _id - - -class _KeyProto(object): - - def __init__(self, id_): - self.path = [_PathElementProto(id_)] - - class _Connection(object): USER_AGENT = 'you-sir-age-int' diff --git a/gcloud/datastore/test_entity.py b/unit_tests/datastore/test_entity.py similarity index 100% rename from gcloud/datastore/test_entity.py rename to unit_tests/datastore/test_entity.py diff --git a/gcloud/datastore/test_helpers.py b/unit_tests/datastore/test_helpers.py similarity index 100% rename from gcloud/datastore/test_helpers.py rename to unit_tests/datastore/test_helpers.py diff --git a/gcloud/datastore/test_key.py b/unit_tests/datastore/test_key.py similarity index 100% rename from gcloud/datastore/test_key.py rename to unit_tests/datastore/test_key.py diff --git a/gcloud/datastore/test_query.py b/unit_tests/datastore/test_query.py similarity index 100% rename from gcloud/datastore/test_query.py rename to unit_tests/datastore/test_query.py diff --git a/gcloud/datastore/test_transaction.py b/unit_tests/datastore/test_transaction.py similarity index 95% rename from gcloud/datastore/test_transaction.py rename to unit_tests/datastore/test_transaction.py index 955e73d7a898..a093a99f7ac2 100644 --- a/gcloud/datastore/test_transaction.py +++ b/unit_tests/datastore/test_transaction.py @@ -41,7 +41,6 @@ def test_ctor_defaults(self): self.assertEqual(len(xact._partial_key_entities), 0) def test_current(self): - from gcloud.datastore.test_client import _NoCommitBatch _PROJECT = 'PROJECT' connection = _Connection() client = _Client(_PROJECT, connection) @@ -221,3 +220,18 @@ def _pop_batch(self): @property def current_batch(self): return self._batches and self._batches[0] or None + + +class _NoCommitBatch(object): + + def __init__(self, client): + from gcloud.datastore.batch import Batch + self._client = client + self._batch = Batch(client) + + def __enter__(self): + self._client._push_batch(self._batch) + return self._batch + + def __exit__(self, *args): + self._client._pop_batch() diff --git a/unit_tests/dns/__init__.py b/unit_tests/dns/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/dns/__init__.py @@ -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. diff --git a/gcloud/dns/test_changes.py b/unit_tests/dns/test_changes.py similarity index 100% rename from gcloud/dns/test_changes.py rename to unit_tests/dns/test_changes.py diff --git a/gcloud/dns/test_client.py b/unit_tests/dns/test_client.py similarity index 100% rename from gcloud/dns/test_client.py rename to unit_tests/dns/test_client.py diff --git a/gcloud/dns/test_connection.py b/unit_tests/dns/test_connection.py similarity index 100% rename from gcloud/dns/test_connection.py rename to unit_tests/dns/test_connection.py diff --git a/gcloud/dns/test_resource_record_set.py b/unit_tests/dns/test_resource_record_set.py similarity index 100% rename from gcloud/dns/test_resource_record_set.py rename to unit_tests/dns/test_resource_record_set.py diff --git a/gcloud/dns/test_zone.py b/unit_tests/dns/test_zone.py similarity index 100% rename from gcloud/dns/test_zone.py rename to unit_tests/dns/test_zone.py diff --git a/unit_tests/error_reporting/__init__.py b/unit_tests/error_reporting/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/error_reporting/__init__.py @@ -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. diff --git a/gcloud/error_reporting/test_client.py b/unit_tests/error_reporting/test_client.py similarity index 100% rename from gcloud/error_reporting/test_client.py rename to unit_tests/error_reporting/test_client.py diff --git a/unit_tests/language/__init__.py b/unit_tests/language/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/language/__init__.py @@ -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. diff --git a/gcloud/language/test_client.py b/unit_tests/language/test_client.py similarity index 100% rename from gcloud/language/test_client.py rename to unit_tests/language/test_client.py diff --git a/gcloud/language/test_connection.py b/unit_tests/language/test_connection.py similarity index 100% rename from gcloud/language/test_connection.py rename to unit_tests/language/test_connection.py diff --git a/gcloud/language/test_document.py b/unit_tests/language/test_document.py similarity index 100% rename from gcloud/language/test_document.py rename to unit_tests/language/test_document.py diff --git a/gcloud/language/test_entity.py b/unit_tests/language/test_entity.py similarity index 100% rename from gcloud/language/test_entity.py rename to unit_tests/language/test_entity.py diff --git a/gcloud/language/test_sentiment.py b/unit_tests/language/test_sentiment.py similarity index 100% rename from gcloud/language/test_sentiment.py rename to unit_tests/language/test_sentiment.py diff --git a/gcloud/language/test_syntax.py b/unit_tests/language/test_syntax.py similarity index 100% rename from gcloud/language/test_syntax.py rename to unit_tests/language/test_syntax.py diff --git a/unit_tests/logging/__init__.py b/unit_tests/logging/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/logging/__init__.py @@ -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. diff --git a/unit_tests/logging/handlers/__init__.py b/unit_tests/logging/handlers/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/logging/handlers/__init__.py @@ -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. diff --git a/gcloud/logging/handlers/test_handlers.py b/unit_tests/logging/handlers/test_handlers.py similarity index 100% rename from gcloud/logging/handlers/test_handlers.py rename to unit_tests/logging/handlers/test_handlers.py diff --git a/unit_tests/logging/handlers/transports/__init__.py b/unit_tests/logging/handlers/transports/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/logging/handlers/transports/__init__.py @@ -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. diff --git a/gcloud/logging/handlers/transports/test_background_thread.py b/unit_tests/logging/handlers/transports/test_background_thread.py similarity index 100% rename from gcloud/logging/handlers/transports/test_background_thread.py rename to unit_tests/logging/handlers/transports/test_background_thread.py diff --git a/gcloud/logging/handlers/transports/test_base.py b/unit_tests/logging/handlers/transports/test_base.py similarity index 100% rename from gcloud/logging/handlers/transports/test_base.py rename to unit_tests/logging/handlers/transports/test_base.py diff --git a/gcloud/logging/handlers/transports/test_sync.py b/unit_tests/logging/handlers/transports/test_sync.py similarity index 100% rename from gcloud/logging/handlers/transports/test_sync.py rename to unit_tests/logging/handlers/transports/test_sync.py diff --git a/gcloud/logging/test__gax.py b/unit_tests/logging/test__gax.py similarity index 98% rename from gcloud/logging/test__gax.py rename to unit_tests/logging/test__gax.py index 342b1ac6548d..cd4795356a44 100644 --- a/gcloud/logging/test__gax.py +++ b/unit_tests/logging/test__gax.py @@ -24,7 +24,7 @@ else: _HAVE_GAX = True -from gcloud._testing import _GAXBaseAPI +from unit_tests._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 gcloud.logging import DESCENDING - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator TOKEN = 'TOKEN' TEXT = 'TEXT' response = _GAXPageIterator( @@ -81,7 +81,7 @@ def test_list_entries_no_paging(self): def test_list_entries_with_paging(self): from google.protobuf.struct_pb2 import Value - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' @@ -115,7 +115,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 gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator from gcloud._helpers import UTC from gcloud._helpers import _datetime_to_rfc3339 from gcloud._helpers import _datetime_to_pb_timestamp @@ -452,7 +452,7 @@ def test_ctor(self): def test_list_sinks_no_paging(self): from google.gax import INITIAL_PAGE - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator TOKEN = 'TOKEN' SINKS = [{ 'name': self.SINK_PATH, @@ -476,7 +476,7 @@ def test_list_sinks_no_paging(self): self.assertEqual(options.page_token, INITIAL_PAGE) def test_list_sinks_w_paging(self): - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator TOKEN = 'TOKEN' PAGE_SIZE = 42 SINKS = [{ @@ -656,7 +656,7 @@ def test_ctor(self): def test_list_metrics_no_paging(self): from google.gax import INITIAL_PAGE - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator TOKEN = 'TOKEN' METRICS = [{ 'name': self.METRIC_PATH, @@ -680,7 +680,7 @@ def test_list_metrics_no_paging(self): self.assertEqual(options.page_token, INITIAL_PAGE) def test_list_metrics_w_paging(self): - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator TOKEN = 'TOKEN' PAGE_SIZE = 42 METRICS = [{ diff --git a/gcloud/logging/test_client.py b/unit_tests/logging/test_client.py similarity index 98% rename from gcloud/logging/test_client.py rename to unit_tests/logging/test_client.py index c1ceb9f685e8..779a5b1729b0 100644 --- a/gcloud/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 gcloud.logging.connection import _LoggingAPI from gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._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 gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey wrapped = object() _called_with = [] @@ -88,7 +88,7 @@ def __init__(self, _wrapped): def test_sinks_api_wo_gax(self): from gcloud.logging.connection import _SinksAPI from gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._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 gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey wrapped = object() _called_with = [] @@ -135,7 +135,7 @@ def __init__(self, _wrapped): def test_metrics_api_wo_gax(self): from gcloud.logging.connection import _MetricsAPI from gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._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 gcloud.logging import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey wrapped = object() _called_with = [] diff --git a/gcloud/logging/test_connection.py b/unit_tests/logging/test_connection.py similarity index 98% rename from gcloud/logging/test_connection.py rename to unit_tests/logging/test_connection.py index 6405d162c78e..7108bf5fff40 100644 --- a/gcloud/logging/test_connection.py +++ b/unit_tests/logging/test_connection.py @@ -58,7 +58,7 @@ def test_ctor(self): def _make_timestamp(): from datetime import datetime from gcloud._helpers import UTC - from gcloud.logging.test_entries import _datetime_to_rfc3339_w_nanos + NOW = datetime.utcnow().replace(tzinfo=UTC) return _datetime_to_rfc3339_w_nanos(NOW) @@ -631,3 +631,9 @@ def api_request(self, **kw): except IndexError: raise NotFound('miss') return response + + +def _datetime_to_rfc3339_w_nanos(value): + from gcloud._helpers import _RFC3339_NO_FRACTION + no_fraction = value.strftime(_RFC3339_NO_FRACTION) + return '%s.%09dZ' % (no_fraction, value.microsecond * 1000) diff --git a/gcloud/logging/test_entries.py b/unit_tests/logging/test_entries.py similarity index 100% rename from gcloud/logging/test_entries.py rename to unit_tests/logging/test_entries.py diff --git a/gcloud/logging/test_logger.py b/unit_tests/logging/test_logger.py similarity index 100% rename from gcloud/logging/test_logger.py rename to unit_tests/logging/test_logger.py diff --git a/gcloud/logging/test_metric.py b/unit_tests/logging/test_metric.py similarity index 100% rename from gcloud/logging/test_metric.py rename to unit_tests/logging/test_metric.py diff --git a/gcloud/logging/test_sink.py b/unit_tests/logging/test_sink.py similarity index 100% rename from gcloud/logging/test_sink.py rename to unit_tests/logging/test_sink.py diff --git a/unit_tests/monitoring/__init__.py b/unit_tests/monitoring/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/monitoring/__init__.py @@ -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. diff --git a/gcloud/monitoring/test__dataframe.py b/unit_tests/monitoring/test__dataframe.py similarity index 100% rename from gcloud/monitoring/test__dataframe.py rename to unit_tests/monitoring/test__dataframe.py diff --git a/gcloud/monitoring/test_client.py b/unit_tests/monitoring/test_client.py similarity index 99% rename from gcloud/monitoring/test_client.py rename to unit_tests/monitoring/test_client.py index 745a0e86d1d5..17edcd1fef0a 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey import gcloud.monitoring.client METRIC_TYPE = 'custom.googleapis.com/my_metric' METRIC_LABELS = { diff --git a/gcloud/monitoring/test_connection.py b/unit_tests/monitoring/test_connection.py similarity index 100% rename from gcloud/monitoring/test_connection.py rename to unit_tests/monitoring/test_connection.py diff --git a/gcloud/monitoring/test_group.py b/unit_tests/monitoring/test_group.py similarity index 100% rename from gcloud/monitoring/test_group.py rename to unit_tests/monitoring/test_group.py diff --git a/gcloud/monitoring/test_label.py b/unit_tests/monitoring/test_label.py similarity index 100% rename from gcloud/monitoring/test_label.py rename to unit_tests/monitoring/test_label.py diff --git a/gcloud/monitoring/test_metric.py b/unit_tests/monitoring/test_metric.py similarity index 100% rename from gcloud/monitoring/test_metric.py rename to unit_tests/monitoring/test_metric.py diff --git a/gcloud/monitoring/test_query.py b/unit_tests/monitoring/test_query.py similarity index 99% rename from gcloud/monitoring/test_query.py rename to unit_tests/monitoring/test_query.py index 720a5ec61678..3cf8d6cc3096 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.monitoring import query as MUT MINUTES = 5 diff --git a/gcloud/monitoring/test_resource.py b/unit_tests/monitoring/test_resource.py similarity index 100% rename from gcloud/monitoring/test_resource.py rename to unit_tests/monitoring/test_resource.py diff --git a/gcloud/monitoring/test_timeseries.py b/unit_tests/monitoring/test_timeseries.py similarity index 100% rename from gcloud/monitoring/test_timeseries.py rename to unit_tests/monitoring/test_timeseries.py diff --git a/unit_tests/pubsub/__init__.py b/unit_tests/pubsub/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/pubsub/__init__.py @@ -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. diff --git a/gcloud/pubsub/test__gax.py b/unit_tests/pubsub/test__gax.py similarity index 98% rename from gcloud/pubsub/test__gax.py rename to unit_tests/pubsub/test__gax.py index a58c0656e107..9908331768a7 100644 --- a/gcloud/pubsub/test__gax.py +++ b/unit_tests/pubsub/test__gax.py @@ -24,7 +24,7 @@ else: _HAVE_GAX = True -from gcloud._testing import _GAXBaseAPI +from unit_tests._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 gcloud._testing import _GAXPageIterator + from unit_tests._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.assertTrue(options.page_token is INITIAL_PAGE) def test_list_topics_with_paging(self): - from gcloud._testing import _GAXPageIterator + from unit_tests._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 gcloud._testing import _GAXPageIterator + from unit_tests._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.assertTrue(options.page_token is INITIAL_PAGE) def test_topic_list_subscriptions_with_paging(self): - from gcloud._testing import _GAXPageIterator + from unit_tests._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 gcloud._testing import _GAXPageIterator + from unit_tests._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.assertTrue(options.page_token is INITIAL_PAGE) def test_list_subscriptions_with_paging(self): - from gcloud._testing import _GAXPageIterator + from unit_tests._testing import _GAXPageIterator SIZE = 23 TOKEN = 'TOKEN' NEW_TOKEN = 'NEW_TOKEN' diff --git a/gcloud/pubsub/test__helpers.py b/unit_tests/pubsub/test__helpers.py similarity index 100% rename from gcloud/pubsub/test__helpers.py rename to unit_tests/pubsub/test__helpers.py diff --git a/gcloud/pubsub/test_client.py b/unit_tests/pubsub/test_client.py similarity index 98% rename from gcloud/pubsub/test_client.py rename to unit_tests/pubsub/test_client.py index aa8923df0f2c..3b3a95ff6175 100644 --- a/gcloud/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 gcloud.pubsub.connection import _PublisherAPI from gcloud.pubsub import client as MUT - from gcloud._testing import _Monkey + from unit_tests._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 gcloud.pubsub import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey wrapped = object() _called_with = [] @@ -80,7 +80,7 @@ def __init__(self, _wrapped): def test_subscriber_api_wo_gax(self): from gcloud.pubsub.connection import _SubscriberAPI from gcloud.pubsub import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey creds = _Credentials() client = self._makeOne(project=self.PROJECT, credentials=creds) conn = client.connection = object() @@ -96,7 +96,7 @@ def test_subscriber_api_wo_gax(self): def test_subscriber_api_w_gax(self): from gcloud.pubsub import client as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey wrapped = object() _called_with = [] diff --git a/gcloud/pubsub/test_connection.py b/unit_tests/pubsub/test_connection.py similarity index 99% rename from gcloud/pubsub/test_connection.py rename to unit_tests/pubsub/test_connection.py index a317488cbbab..8d356f46c37f 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.environment_vars import PUBSUB_EMULATOR HOST = 'localhost:8187' @@ -65,7 +65,7 @@ def test_custom_url_from_constructor(self): def test_custom_url_constructor_and_env(self): import os - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.environment_vars import PUBSUB_EMULATOR HOST1 = object() diff --git a/gcloud/pubsub/test_iam.py b/unit_tests/pubsub/test_iam.py similarity index 100% rename from gcloud/pubsub/test_iam.py rename to unit_tests/pubsub/test_iam.py diff --git a/gcloud/pubsub/test_message.py b/unit_tests/pubsub/test_message.py similarity index 100% rename from gcloud/pubsub/test_message.py rename to unit_tests/pubsub/test_message.py diff --git a/gcloud/pubsub/test_subscription.py b/unit_tests/pubsub/test_subscription.py similarity index 100% rename from gcloud/pubsub/test_subscription.py rename to unit_tests/pubsub/test_subscription.py diff --git a/gcloud/pubsub/test_topic.py b/unit_tests/pubsub/test_topic.py similarity index 99% rename from gcloud/pubsub/test_topic.py rename to unit_tests/pubsub/test_topic.py index e650d2068475..b9fa94698cb6 100644 --- a/gcloud/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 gcloud.pubsub import topic as MUT from gcloud._helpers import _RFC3339_MICROS - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey NOW = datetime.datetime.utcnow() def _utcnow(): diff --git a/unit_tests/resource_manager/__init__.py b/unit_tests/resource_manager/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/resource_manager/__init__.py @@ -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. diff --git a/gcloud/resource_manager/test_client.py b/unit_tests/resource_manager/test_client.py similarity index 100% rename from gcloud/resource_manager/test_client.py rename to unit_tests/resource_manager/test_client.py diff --git a/gcloud/resource_manager/test_connection.py b/unit_tests/resource_manager/test_connection.py similarity index 100% rename from gcloud/resource_manager/test_connection.py rename to unit_tests/resource_manager/test_connection.py diff --git a/gcloud/resource_manager/test_project.py b/unit_tests/resource_manager/test_project.py similarity index 100% rename from gcloud/resource_manager/test_project.py rename to unit_tests/resource_manager/test_project.py diff --git a/unit_tests/storage/__init__.py b/unit_tests/storage/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/storage/__init__.py @@ -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. diff --git a/gcloud/storage/test__helpers.py b/unit_tests/storage/test__helpers.py similarity index 99% rename from gcloud/storage/test__helpers.py rename to unit_tests/storage/test__helpers.py index 87c7108599ca..9f12d6d9908d 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.storage import _helpers as MUT class _Buffer(object): diff --git a/gcloud/storage/test_acl.py b/unit_tests/storage/test_acl.py similarity index 100% rename from gcloud/storage/test_acl.py rename to unit_tests/storage/test_acl.py diff --git a/gcloud/storage/test_batch.py b/unit_tests/storage/test_batch.py similarity index 100% rename from gcloud/storage/test_batch.py rename to unit_tests/storage/test_batch.py diff --git a/gcloud/storage/test_blob.py b/unit_tests/storage/test_blob.py similarity index 97% rename from gcloud/storage/test_blob.py rename to unit_tests/storage/test_blob.py index 395f57868b20..0f1e73cf071c 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.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 gcloud._testing import _NamedTemporaryFile + from unit_tests._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 gcloud._testing import _NamedTemporaryFile + from unit_tests._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 gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _NamedTemporaryFile BLOB_NAME = 'blob-name' DATA = b'ABCDEF' @@ -532,7 +532,6 @@ def test_upload_from_file_stream(self): blob._CHUNK_SIZE_MULTIPLE = 1 blob.chunk_size = 5 - from gcloud.streaming.test_transfer import _Stream file_obj = _Stream(DATA) # Mock stream closes at end of data, like a socket might @@ -642,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 gcloud._testing import _Monkey - from gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _Monkey + from unit_tests._testing import _NamedTemporaryFile from gcloud.streaming import http_wrapper from gcloud.streaming import transfer @@ -726,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 gcloud._testing import _Monkey - from gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _Monkey + from unit_tests._testing import _NamedTemporaryFile from gcloud.streaming import transfer from gcloud.streaming.exceptions import HttpError @@ -780,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 gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _NamedTemporaryFile from gcloud.streaming import http_wrapper BLOB_NAME = 'parent/child' @@ -830,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 gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _NamedTemporaryFile from gcloud.streaming import http_wrapper BLOB_NAME = 'blob-name' @@ -889,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 gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _NamedTemporaryFile from gcloud.streaming import http_wrapper BLOB_NAME = 'blob-name' @@ -1492,3 +1491,24 @@ def __init__(self, connection): @property def connection(self): return self._connection + + +class _Stream(object): + _closed = False + + def __init__(self, to_read=b''): + import io + self._written = [] + self._to_read = io.BytesIO(to_read) + + def seek(self, offset, whence=0): + self._to_read.seek(offset, whence) + + def read(self, size): + return self._to_read.read(size) + + def tell(self): + return self._to_read.tell() + + def close(self): + self._closed = True diff --git a/gcloud/storage/test_bucket.py b/unit_tests/storage/test_bucket.py similarity index 100% rename from gcloud/storage/test_bucket.py rename to unit_tests/storage/test_bucket.py diff --git a/gcloud/storage/test_client.py b/unit_tests/storage/test_client.py similarity index 100% rename from gcloud/storage/test_client.py rename to unit_tests/storage/test_client.py diff --git a/gcloud/storage/test_connection.py b/unit_tests/storage/test_connection.py similarity index 100% rename from gcloud/storage/test_connection.py rename to unit_tests/storage/test_connection.py diff --git a/unit_tests/streaming/__init__.py b/unit_tests/streaming/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/streaming/__init__.py @@ -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. diff --git a/gcloud/streaming/test_buffered_stream.py b/unit_tests/streaming/test_buffered_stream.py similarity index 100% rename from gcloud/streaming/test_buffered_stream.py rename to unit_tests/streaming/test_buffered_stream.py diff --git a/gcloud/streaming/test_exceptions.py b/unit_tests/streaming/test_exceptions.py similarity index 100% rename from gcloud/streaming/test_exceptions.py rename to unit_tests/streaming/test_exceptions.py diff --git a/gcloud/streaming/test_http_wrapper.py b/unit_tests/streaming/test_http_wrapper.py similarity index 97% rename from gcloud/streaming/test_http_wrapper.py rename to unit_tests/streaming/test_http_wrapper.py index d1bdd8617292..0a40a3c361b9 100644 --- a/gcloud/streaming/test_http_wrapper.py +++ b/unit_tests/streaming/test_http_wrapper.py @@ -11,7 +11,7 @@ def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_wo_loggable_body_wo_http(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT request = _Request() @@ -22,7 +22,7 @@ def test_wo_loggable_body_wo_http(self): self.assertEqual(_httplib2.debuglevel, 0) def test_w_loggable_body_wo_http(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT request = _Request(loggable_body=object()) @@ -34,7 +34,7 @@ def test_w_loggable_body_wo_http(self): self.assertEqual(_httplib2.debuglevel, 0) def test_w_loggable_body_w_http(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT class _Connection(object): @@ -269,7 +269,7 @@ def _verify_requested(self, http, request, self.assertEqual(kw['connection_type'], connection_type) def test_defaults_wo_connections(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -288,7 +288,7 @@ def test_defaults_wo_connections(self): self._verify_requested(_http, _request) def test_w_explicit_redirections(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -308,7 +308,7 @@ def test_w_explicit_redirections(self): self._verify_requested(_http, _request, redirections=10) def test_w_http_connections_miss(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -329,7 +329,7 @@ def test_w_http_connections_miss(self): self._verify_requested(_http, _request) def test_w_http_connections_hit(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT INFO = {'status': '200'} CONTENT = 'CONTENT' @@ -350,7 +350,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT from gcloud.streaming.exceptions import RequestError INFO = None @@ -424,7 +424,7 @@ def _wo_exception(*args, **kw): self.assertEqual(_checked, []) # not called by '_wo_exception' def test_w_exceptions_gt_max_retries(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT HTTP = object() REQUEST = _Request() @@ -460,7 +460,7 @@ def _callFUT(self, *args, **kw): return _register_http_factory(*args, **kw) def test_it(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT _factories = [] @@ -479,7 +479,7 @@ def _callFUT(self, *args, **kw): def test_wo_registered_factories(self): from httplib2 import Http - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT _factories = [] @@ -489,7 +489,7 @@ def test_wo_registered_factories(self): self.assertTrue(isinstance(http, Http)) def test_w_registered_factories(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import http_wrapper as MUT FOUND = object() diff --git a/gcloud/streaming/test_stream_slice.py b/unit_tests/streaming/test_stream_slice.py similarity index 100% rename from gcloud/streaming/test_stream_slice.py rename to unit_tests/streaming/test_stream_slice.py diff --git a/gcloud/streaming/test_transfer.py b/unit_tests/streaming/test_transfer.py similarity index 98% rename from gcloud/streaming/test_transfer.py rename to unit_tests/streaming/test_transfer.py index c84d2fd48aff..2857e4639c0e 100644 --- a/gcloud/streaming/test_transfer.py +++ b/unit_tests/streaming/test_transfer.py @@ -275,7 +275,7 @@ def test_initialize_download_wo_autotransfer(self): def test_initialize_download_w_autotransfer_failing(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import HttpError request = _Request() @@ -294,7 +294,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT REDIRECT_URL = 'http://example.com/other' request = _Request() @@ -411,7 +411,7 @@ def test__get_chunk_not_initialized(self): def test__get_chunk(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT http = object() download = self._makeOne(_Stream()) @@ -507,7 +507,7 @@ def test_get_range_not_initialized(self): def test_get_range_wo_total_size_complete(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -534,7 +534,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -563,7 +563,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -592,7 +592,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import TransferRetryError CONTENT = b'ABCDEFGHIJ' @@ -623,7 +623,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -651,7 +651,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDE' LEN = len(CONTENT) @@ -712,7 +712,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CHUNK_SIZE = 3 CONTENT = b'ABCDEF' @@ -749,7 +749,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1124,7 +1124,7 @@ def test_refresh_upload_state_not_initialized(self): def test_refresh_upload_state_w_OK(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1151,7 +1151,7 @@ def test_refresh_upload_state_w_OK(self): def test_refresh_upload_state_w_CREATED(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1179,7 +1179,7 @@ def test_refresh_upload_state_w_CREATED(self): def test_refresh_upload_state_w_RESUME_INCOMPLETE_w_range(self): from gcloud.streaming import transfer as MUT from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1206,7 +1206,7 @@ def test_refresh_upload_state_w_RESUME_INCOMPLETE_w_range(self): def test_refresh_upload_state_w_RESUME_INCOMPLETE_wo_range(self): from gcloud.streaming import transfer as MUT from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' LEN = len(CONTENT) @@ -1230,7 +1230,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import HttpError from gcloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1290,7 +1290,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import HttpError from gcloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1306,7 +1306,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.transfer import RESUMABLE_UPLOAD request = _Request() @@ -1327,7 +1327,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1479,7 +1479,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE from gcloud.streaming.transfer import RESUMABLE_UPLOAD @@ -1523,7 +1523,7 @@ def test_stream_file_incomplete(self): self.assertEqual(request_2.body, CONTENT[6:]) def test_stream_file_incomplete_w_transfer_error(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import CommunicationError from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE @@ -1561,7 +1561,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE CONTENT = b'ABCDEFGHIJ' @@ -1589,7 +1589,7 @@ def test__send_media_request_wo_error(self): def test__send_media_request_w_error(self): from six.moves import http_client - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud.streaming import transfer as MUT from gcloud.streaming.exceptions import HttpError from gcloud.streaming.http_wrapper import RESUME_INCOMPLETE diff --git a/gcloud/streaming/test_util.py b/unit_tests/streaming/test_util.py similarity index 94% rename from gcloud/streaming/test_util.py rename to unit_tests/streaming/test_util.py index 560eba4dd1d6..0d4d9d89f63c 100644 --- a/gcloud/streaming/test_util.py +++ b/unit_tests/streaming/test_util.py @@ -9,13 +9,13 @@ def _callFUT(self, *args, **kw): def test_w_negative_jitter_lt_max_wait(self): import random - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey with _Monkey(random, uniform=lambda lower, upper: lower): self.assertEqual(self._callFUT(1, 60), 1.5) def test_w_positive_jitter_gt_max_wait(self): import random - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey with _Monkey(random, uniform=lambda lower, upper: upper): self.assertEqual(self._callFUT(4, 10), 10) diff --git a/gcloud/test__helpers.py b/unit_tests/test__helpers.py similarity index 98% rename from gcloud/test__helpers.py rename to unit_tests/test__helpers.py index 06b69f6bf727..87468b55ca3a 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import _helpers with _Monkey(_helpers, app_identity=None): @@ -139,7 +139,7 @@ def test_no_value(self): self.assertEqual(dataset_id, None) def test_value_set(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import _helpers APP_ENGINE_ID = object() @@ -164,7 +164,7 @@ def tearDown(self): del os.environ['GOOGLE_APPLICATION_CREDENTIALS'] def test_success(self): - from gcloud._testing import _NamedTemporaryFile + from unit_tests._testing import _NamedTemporaryFile with _NamedTemporaryFile() as temp: with open(temp.name, mode='w') as creds_file: @@ -209,7 +209,7 @@ def tearDown(self): def _callFUT(self, project_id=None): from gcloud._helpers import _default_service_project_id - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey def mock_expanduser(path=None): if project_id and path: @@ -250,7 +250,7 @@ def _callFUT(self): return _compute_engine_id() def _monkeyConnection(self, connection): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import _helpers def _connection_factory(host, timeout): @@ -287,7 +287,7 @@ def _callFUT(self): return _get_production_project() def test_no_value(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey environ = {} with _Monkey(os, getenv=environ.get): @@ -295,7 +295,7 @@ def test_no_value(self): self.assertEqual(project, None) def test_value_set(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud._helpers import PROJECT MOCK_PROJECT = object() @@ -313,7 +313,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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import _helpers _callers = [] @@ -853,7 +853,7 @@ def _callFUT(self, *args, **kwargs): return make_stub(*args, **kwargs) def test_it(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import _helpers as MUT mock_result = object() diff --git a/gcloud/test_client.py b/unit_tests/test_client.py similarity index 96% rename from gcloud/test_client.py rename to unit_tests/test_client.py index 65d5136ff115..17e28b32216b 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import client CREDENTIALS = object() @@ -72,7 +72,7 @@ def test_ctor_explicit(self): self.assertTrue(client_obj.connection.http is HTTP) def test_from_service_account_json(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import client KLASS = self._getTargetClass() @@ -92,7 +92,7 @@ def test_from_service_account_json_fail(self): credentials=CREDENTIALS) def test_from_service_account_p12(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import client KLASS = self._getTargetClass() @@ -134,7 +134,7 @@ def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_ctor_defaults(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import client PROJECT = 'PROJECT' @@ -161,7 +161,7 @@ def mock_get_credentials(): [(None, '_determine_default_project'), 'get_credentials']) def test_ctor_missing_project(self): - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import client FUNC_CALLS = [] diff --git a/gcloud/test_connection.py b/unit_tests/test_connection.py similarity index 100% rename from gcloud/test_connection.py rename to unit_tests/test_connection.py diff --git a/gcloud/test_credentials.py b/unit_tests/test_credentials.py similarity index 97% rename from gcloud/test_credentials.py rename to unit_tests/test_credentials.py index 82ce4f234e27..78fe9c5d2e32 100644 --- a/gcloud/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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud 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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud 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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud 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 gcloud._testing import _Monkey + from unit_tests._testing import _Monkey from gcloud import credentials as MUT dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0) diff --git a/gcloud/test_exceptions.py b/unit_tests/test_exceptions.py similarity index 100% rename from gcloud/test_exceptions.py rename to unit_tests/test_exceptions.py diff --git a/gcloud/test_iterator.py b/unit_tests/test_iterator.py similarity index 100% rename from gcloud/test_iterator.py rename to unit_tests/test_iterator.py diff --git a/gcloud/test_operation.py b/unit_tests/test_operation.py similarity index 97% rename from gcloud/test_operation.py rename to unit_tests/test_operation.py index be7aa89a3854..a23f15604fed 100644 --- a/gcloud/test_operation.py +++ b/unit_tests/test_operation.py @@ -52,7 +52,7 @@ def _callFUT(self, type_url, klass): def test_simple(self): from gcloud import operation as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey TYPE_URI = 'testing.gcloud-python.com/testing' klass = object() type_url_map = {} @@ -64,7 +64,7 @@ def test_simple(self): def test_w_same_class(self): from gcloud import operation as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey TYPE_URI = 'testing.gcloud-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 gcloud import operation as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey TYPE_URI = 'testing.gcloud-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 gcloud import operation as MUT - from gcloud._testing import _Monkey + from unit_tests._testing import _Monkey TYPE_URI = 'type.googleapis.com/%s' % (Struct.DESCRIPTOR.full_name,) type_url_map = {TYPE_URI: Struct} diff --git a/unit_tests/translate/__init__.py b/unit_tests/translate/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/translate/__init__.py @@ -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. diff --git a/gcloud/translate/test_client.py b/unit_tests/translate/test_client.py similarity index 100% rename from gcloud/translate/test_client.py rename to unit_tests/translate/test_client.py diff --git a/gcloud/translate/test_connection.py b/unit_tests/translate/test_connection.py similarity index 100% rename from gcloud/translate/test_connection.py rename to unit_tests/translate/test_connection.py diff --git a/unit_tests/vision/__init__.py b/unit_tests/vision/__init__.py new file mode 100644 index 000000000000..c098733431fd --- /dev/null +++ b/unit_tests/vision/__init__.py @@ -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. diff --git a/gcloud/vision/test_client.py b/unit_tests/vision/test_client.py similarity index 100% rename from gcloud/vision/test_client.py rename to unit_tests/vision/test_client.py diff --git a/gcloud/vision/test_connection.py b/unit_tests/vision/test_connection.py similarity index 100% rename from gcloud/vision/test_connection.py rename to unit_tests/vision/test_connection.py diff --git a/gcloud/vision/test_feature.py b/unit_tests/vision/test_feature.py similarity index 100% rename from gcloud/vision/test_feature.py rename to unit_tests/vision/test_feature.py diff --git a/gcloud/vision/test_image.py b/unit_tests/vision/test_image.py similarity index 100% rename from gcloud/vision/test_image.py rename to unit_tests/vision/test_image.py