From 06f5a72e30970f97aa0b9b2480249201201b4de1 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Thu, 3 Nov 2016 11:38:28 -0700 Subject: [PATCH 01/12] Configuration for new Firestore SDK. --- .gitignore | 1 + firestore/MANIFEST.in | 5 ++ firestore/README.rst | 2 + firestore/google/__init__.py | 1 + firestore/google/cloud/__init__.py | 1 + firestore/google/cloud/firestore/__init__.py | 16 +++++ firestore/google/cloud/firestore/firestore.py | 27 +++++++ firestore/requirements.txt | 5 ++ firestore/setup.cfg | 2 + firestore/setup.py | 72 +++++++++++++++++++ firestore/tox.ini | 30 ++++++++ firestore/unit_tests/test_firestore.py | 26 +++++++ 12 files changed, 188 insertions(+) create mode 100644 firestore/MANIFEST.in create mode 100644 firestore/README.rst create mode 100644 firestore/google/__init__.py create mode 100644 firestore/google/cloud/__init__.py create mode 100644 firestore/google/cloud/firestore/__init__.py create mode 100644 firestore/google/cloud/firestore/firestore.py create mode 100644 firestore/requirements.txt create mode 100644 firestore/setup.cfg create mode 100644 firestore/setup.py create mode 100644 firestore/tox.ini create mode 100644 firestore/unit_tests/test_firestore.py diff --git a/.gitignore b/.gitignore index 8e4001cb4b125..874f87b61cc0b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ coverage.xml # System test environment variables. system_tests/local_test_setup +system_tests/app_credentials.json # Make sure a generated file isn't accidentally committed. scripts/pylintrc_reduced diff --git a/firestore/MANIFEST.in b/firestore/MANIFEST.in new file mode 100644 index 0000000000000..b35b665f32cec --- /dev/null +++ b/firestore/MANIFEST.in @@ -0,0 +1,5 @@ +include README.rst +graft google +graft unit_tests +global-include *.json +global-exclude *.pyc diff --git a/firestore/README.rst b/firestore/README.rst new file mode 100644 index 0000000000000..df0cb635f03be --- /dev/null +++ b/firestore/README.rst @@ -0,0 +1,2 @@ +Google Cloud Firestore SDK +========================== diff --git a/firestore/google/__init__.py b/firestore/google/__init__.py new file mode 100644 index 0000000000000..de40ea7ca058e --- /dev/null +++ b/firestore/google/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/firestore/google/cloud/__init__.py b/firestore/google/cloud/__init__.py new file mode 100644 index 0000000000000..de40ea7ca058e --- /dev/null +++ b/firestore/google/cloud/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/firestore/google/cloud/firestore/__init__.py b/firestore/google/cloud/firestore/__init__.py new file mode 100644 index 0000000000000..ff0ace3e9a7a4 --- /dev/null +++ b/firestore/google/cloud/firestore/__init__.py @@ -0,0 +1,16 @@ +# 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. +"""Firestore database API public classes.""" + +from google.cloud.firestore.firestore import Firestore diff --git a/firestore/google/cloud/firestore/firestore.py b/firestore/google/cloud/firestore/firestore.py new file mode 100644 index 0000000000000..4c84b558924f1 --- /dev/null +++ b/firestore/google/cloud/firestore/firestore.py @@ -0,0 +1,27 @@ +# 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. +"""Firestore database API.""" + + +class Firestore(object): + """Top level Firestore database instance.""" + + # pylint: disable=unused-argument + def __init__(self, project_id=None, channel=None): + if project_id is None: + raise Exception('Missing project id.') + self.project_id = project_id + self.database_id = None + + # pylint: enable=unused-argument diff --git a/firestore/requirements.txt b/firestore/requirements.txt new file mode 100644 index 0000000000000..cd7618f74d3ab --- /dev/null +++ b/firestore/requirements.txt @@ -0,0 +1,5 @@ +googleapis-common-protos>=1.3.4, <2.0.0dev +google-gax>=0.14.1, <0.15.0dev +# TODO (https://github.com/googleapis/packman/issues/119): need upper bound logic +grpc-google-firestore-v1alpha1>=0.10.0 +oauth2client>=3.0.0, <4.0.0dev diff --git a/firestore/setup.cfg b/firestore/setup.cfg new file mode 100644 index 0000000000000..2a9acf13daa95 --- /dev/null +++ b/firestore/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/firestore/setup.py b/firestore/setup.py new file mode 100644 index 0000000000000..79ca17d47e8c3 --- /dev/null +++ b/firestore/setup.py @@ -0,0 +1,72 @@ +# Copyright 2016 Google Inc. +# +# 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. + +import os + +from setuptools import find_packages +from setuptools import setup + + +PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(PACKAGE_ROOT, 'README.rst')) as file_obj: + README = file_obj.read() + + +# NOTE: This is duplicated throughout and we should try to +# consolidate. +SETUP_BASE = { + 'author': 'Google Cloud Platform', + 'author_email': 'jjg+google-cloud-python@google.com', + 'scripts': [], + 'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python', + 'license': 'Apache 2.0', + 'platforms': 'Posix; MacOS X; Windows', + 'include_package_data': True, + 'zip_safe': False, + 'classifiers': [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Topic :: Internet', + ], +} + +REQUIREMENTS = [ + 'grpcio>=1.0.0, <2.0.0dev', + 'googleapis-common-protos>=1.3.4, <2.0.0dev', + 'google-gax>=0.14.1, <0.15.0dev', + 'oauth2client>=3.0.0, <4.0.0dev', + 'google-cloud-core>=0.20' +] + +setup( + name='google-cloud-firestore', + version='0.2.0', + description='Python Client for Google Cloud Firestore', + long_description=README, + namespace_packages=[ + 'google', + 'google.cloud', + ], + packages=find_packages(), + install_requires=REQUIREMENTS, + **SETUP_BASE +) diff --git a/firestore/tox.ini b/firestore/tox.ini new file mode 100644 index 0000000000000..81f175dfdf880 --- /dev/null +++ b/firestore/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = + py27,py34,py35,cover + +[testing] +deps = + {toxinidir}/../core + pytest +covercmd = + py.test --quiet \ + --cov=google.cloud.firestore \ + --cov=unit_tests \ + --cov-config {toxinidir}/.coveragerc \ + unit_tests + +[testenv] +commands = + py.test --quiet {posargs} unit_tests +deps = + {[testing]deps} + +[testenv:cover] +basepython = + python2.7 +commands = + {[testing]covercmd} +deps = + {[testenv]deps} + coverage + pytest-cov diff --git a/firestore/unit_tests/test_firestore.py b/firestore/unit_tests/test_firestore.py new file mode 100644 index 0000000000000..c07d480e03b4f --- /dev/null +++ b/firestore/unit_tests/test_firestore.py @@ -0,0 +1,26 @@ +# 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. +"""Unit tests for Google Firestore SDK.""" + +import unittest + +from google.cloud.firestore import Firestore + + +class TestFirestore(unittest.TestCase): + """Unit Tests for the google.cloud.firestore.Firestore.""" + + def test_empty_constructor(self): + with self.assertRaisesRegexp(Exception, 'project id'): + Firestore() From 8bccdad0fd92caa663979961ae6c29f64c11734e Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Thu, 3 Nov 2016 12:11:45 -0700 Subject: [PATCH 02/12] Fix coverage. --- firestore/.coveragerc | 13 +++++++++++++ firestore/unit_tests/test_firestore.py | 4 ++++ tox.ini | 7 +++++++ 3 files changed, 24 insertions(+) create mode 100644 firestore/.coveragerc diff --git a/firestore/.coveragerc b/firestore/.coveragerc new file mode 100644 index 0000000000000..08f3fdea24339 --- /dev/null +++ b/firestore/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +omit = + */_generated/*.py +fail_under = 100 +show_missing = True +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/firestore/unit_tests/test_firestore.py b/firestore/unit_tests/test_firestore.py index c07d480e03b4f..26de1cfd15baa 100644 --- a/firestore/unit_tests/test_firestore.py +++ b/firestore/unit_tests/test_firestore.py @@ -24,3 +24,7 @@ class TestFirestore(unittest.TestCase): def test_empty_constructor(self): with self.assertRaisesRegexp(Exception, 'project id'): Firestore() + + def test_constructor(self): + db = Firestore('my-project-id') + self.assertIsNotNone(db) diff --git a/tox.ini b/tox.ini index af0055a4b1394..4ca5944498552 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ deps = {toxinidir}/bigtable {toxinidir}/storage {toxinidir}/datastore + {toxinidir}/firestore {toxinidir}/bigquery {toxinidir}/pubsub {toxinidir}/logging @@ -45,6 +46,12 @@ covercmd = --cov-append \ --cov-config {toxinidir}/.coveragerc \ datastore/unit_tests + py.test --quiet \ + --cov=google.cloud \ + --cov=unit_tests \ + --cov-append \ + --cov-config {toxinidir}/.coveragerc \ + firestore/unit_tests py.test --quiet \ --cov=google.cloud \ --cov=unit_tests \ From 25e02bac1b37cf39d723fbe5fdf5000d21a3e6db Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Thu, 3 Nov 2016 14:00:46 -0700 Subject: [PATCH 03/12] Template for building docs. --- docs/firestore.rst | 6 ++++++ docs/index.rst | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 docs/firestore.rst diff --git a/docs/firestore.rst b/docs/firestore.rst new file mode 100644 index 0000000000000..9135d3c84c7b4 --- /dev/null +++ b/docs/firestore.rst @@ -0,0 +1,6 @@ +Firestore +========= + +.. automodule:: google.cloud.firestore + :members: + :show-inheritance: diff --git a/docs/index.rst b/docs/index.rst index a8401af0aff45..99071cb4e06c5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,13 @@ datastore-batches datastore-helpers +.. toctree:: + :maxdepth: 0 + :hidden: + :caption: Firestore + + Firestore + .. toctree:: :maxdepth: 0 :hidden: From 06f7fae8e52b5f1774602477fb6e19d6089f8280 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Thu, 3 Nov 2016 14:30:45 -0700 Subject: [PATCH 04/12] remove .gitignore from this PR --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 874f87b61cc0b..8e4001cb4b125 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,6 @@ coverage.xml # System test environment variables. system_tests/local_test_setup -system_tests/app_credentials.json # Make sure a generated file isn't accidentally committed. scripts/pylintrc_reduced From 0eb4f310a0f176ac26ee9d7c551cb1005b5f70dd Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Mon, 7 Nov 2016 17:09:24 -0800 Subject: [PATCH 05/12] review comments addressed --- docs/index.rst | 2 +- firestore/.coveragerc | 2 -- firestore/google/__init__.py | 22 ++++++++++++++++++- firestore/google/cloud/__init__.py | 22 ++++++++++++++++++- firestore/google/cloud/firestore/__init__.py | 2 +- .../firestore/{firestore.py => client.py} | 16 ++++++++------ firestore/requirements.txt | 5 ----- firestore/setup.py | 3 ++- .../{test_firestore.py => test_client.py} | 6 ++--- 9 files changed, 58 insertions(+), 22 deletions(-) rename firestore/google/cloud/firestore/{firestore.py => client.py} (73%) delete mode 100644 firestore/requirements.txt rename firestore/unit_tests/{test_firestore.py => test_client.py} (89%) diff --git a/docs/index.rst b/docs/index.rst index 99071cb4e06c5..b098aa20b66b9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,7 +28,7 @@ :hidden: :caption: Firestore - Firestore + firestore .. toctree:: :maxdepth: 0 diff --git a/firestore/.coveragerc b/firestore/.coveragerc index 08f3fdea24339..a54b99aa14b7a 100644 --- a/firestore/.coveragerc +++ b/firestore/.coveragerc @@ -2,8 +2,6 @@ branch = True [report] -omit = - */_generated/*.py fail_under = 100 show_missing = True exclude_lines = diff --git a/firestore/google/__init__.py b/firestore/google/__init__.py index de40ea7ca058e..9cc5be46a3073 100644 --- a/firestore/google/__init__.py +++ b/firestore/google/__init__.py @@ -1 +1,21 @@ -__import__('pkg_resources').declare_namespace(__name__) + +# Copyright 2016 Google Inc. +# +# 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. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/firestore/google/cloud/__init__.py b/firestore/google/cloud/__init__.py index de40ea7ca058e..9cc5be46a3073 100644 --- a/firestore/google/cloud/__init__.py +++ b/firestore/google/cloud/__init__.py @@ -1 +1,21 @@ -__import__('pkg_resources').declare_namespace(__name__) + +# Copyright 2016 Google Inc. +# +# 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. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/firestore/google/cloud/firestore/__init__.py b/firestore/google/cloud/firestore/__init__.py index ff0ace3e9a7a4..f3003f9324234 100644 --- a/firestore/google/cloud/firestore/__init__.py +++ b/firestore/google/cloud/firestore/__init__.py @@ -13,4 +13,4 @@ # limitations under the License. """Firestore database API public classes.""" -from google.cloud.firestore.firestore import Firestore +from google.cloud.firestore.client import Client diff --git a/firestore/google/cloud/firestore/firestore.py b/firestore/google/cloud/firestore/client.py similarity index 73% rename from firestore/google/cloud/firestore/firestore.py rename to firestore/google/cloud/firestore/client.py index 4c84b558924f1..e3388ebefa33b 100644 --- a/firestore/google/cloud/firestore/firestore.py +++ b/firestore/google/cloud/firestore/client.py @@ -11,17 +11,19 @@ # 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. + """Firestore database API.""" -class Firestore(object): - """Top level Firestore database instance.""" +class Client(object): + """Top level Firestore database instance. + + :type project_id: str + :param project_id: Project containing the Firestore database. + """ - # pylint: disable=unused-argument - def __init__(self, project_id=None, channel=None): + def __init__(self, project_id=None): if project_id is None: - raise Exception('Missing project id.') + raise ValueError('Missing project id.') self.project_id = project_id self.database_id = None - - # pylint: enable=unused-argument diff --git a/firestore/requirements.txt b/firestore/requirements.txt deleted file mode 100644 index cd7618f74d3ab..0000000000000 --- a/firestore/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -googleapis-common-protos>=1.3.4, <2.0.0dev -google-gax>=0.14.1, <0.15.0dev -# TODO (https://github.com/googleapis/packman/issues/119): need upper bound logic -grpc-google-firestore-v1alpha1>=0.10.0 -oauth2client>=3.0.0, <4.0.0dev diff --git a/firestore/setup.py b/firestore/setup.py index 79ca17d47e8c3..81601c8c2a9b3 100644 --- a/firestore/setup.py +++ b/firestore/setup.py @@ -54,7 +54,8 @@ 'googleapis-common-protos>=1.3.4, <2.0.0dev', 'google-gax>=0.14.1, <0.15.0dev', 'oauth2client>=3.0.0, <4.0.0dev', - 'google-cloud-core>=0.20' + 'google-cloud-core>=0.20', + 'grpc-google-firestore-v1alpha1>=0.10.0' ] setup( diff --git a/firestore/unit_tests/test_firestore.py b/firestore/unit_tests/test_client.py similarity index 89% rename from firestore/unit_tests/test_firestore.py rename to firestore/unit_tests/test_client.py index 26de1cfd15baa..a91c2d2f69c65 100644 --- a/firestore/unit_tests/test_firestore.py +++ b/firestore/unit_tests/test_client.py @@ -15,7 +15,7 @@ import unittest -from google.cloud.firestore import Firestore +from google.cloud.firestore import Client class TestFirestore(unittest.TestCase): @@ -23,8 +23,8 @@ class TestFirestore(unittest.TestCase): def test_empty_constructor(self): with self.assertRaisesRegexp(Exception, 'project id'): - Firestore() + Client() def test_constructor(self): - db = Firestore('my-project-id') + db = Client('my-project-id') self.assertIsNotNone(db) From ff9852ee5b7aa46ad08d384b6d9980ba7d92fb10 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Mon, 7 Nov 2016 17:21:05 -0800 Subject: [PATCH 06/12] add firestore module --- scripts/verify_included_modules.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/verify_included_modules.py b/scripts/verify_included_modules.py index 2e300e196a069..862b495435c7c 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -62,6 +62,7 @@ 'datastore', 'dns', 'error_reporting', + 'firestore', 'language', 'logging', 'monitoring', From 99006c77878fe0fb2443aebaf747db158c8a0609 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Mon, 7 Nov 2016 17:23:07 -0800 Subject: [PATCH 07/12] bump version to current 0.20 --- firestore/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firestore/setup.py b/firestore/setup.py index 81601c8c2a9b3..67e7ea956b92e 100644 --- a/firestore/setup.py +++ b/firestore/setup.py @@ -60,7 +60,7 @@ setup( name='google-cloud-firestore', - version='0.2.0', + version='0.20.0', description='Python Client for Google Cloud Firestore', long_description=README, namespace_packages=[ From 10880ee8402c2ed6a65285310759a37fce681fac Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Tue, 8 Nov 2016 10:02:40 -0800 Subject: [PATCH 08/12] remove unused dependency --- firestore/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/firestore/setup.py b/firestore/setup.py index 67e7ea956b92e..1822540e0970c 100644 --- a/firestore/setup.py +++ b/firestore/setup.py @@ -55,7 +55,6 @@ 'google-gax>=0.14.1, <0.15.0dev', 'oauth2client>=3.0.0, <4.0.0dev', 'google-cloud-core>=0.20', - 'grpc-google-firestore-v1alpha1>=0.10.0' ] setup( From 41431db4d355c1ebba48a940230f999dce5a98a0 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Tue, 8 Nov 2016 10:20:37 -0800 Subject: [PATCH 09/12] Generate docs for Firestore and Client. --- docs/firestore.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/firestore.rst b/docs/firestore.rst index 9135d3c84c7b4..0dbe39ad59363 100644 --- a/docs/firestore.rst +++ b/docs/firestore.rst @@ -4,3 +4,9 @@ Firestore .. automodule:: google.cloud.firestore :members: :show-inheritance: + +Firestore Client +~~~~~~~~~~~~~~~~ +.. automodule:: google.cloud.firestore.client + :members: + :show-inheritance: From f492212e503a2dcb99ae8d5b8da3e54480b0f4ce Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Tue, 8 Nov 2016 10:59:59 -0800 Subject: [PATCH 10/12] Use google.cloud.client.Client as base. --- firestore/google/cloud/firestore/client.py | 12 +++++++----- firestore/unit_tests/test_client.py | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/firestore/google/cloud/firestore/client.py b/firestore/google/cloud/firestore/client.py index e3388ebefa33b..089a4119e3c53 100644 --- a/firestore/google/cloud/firestore/client.py +++ b/firestore/google/cloud/firestore/client.py @@ -14,16 +14,18 @@ """Firestore database API.""" +from google.cloud.client import Client as _BaseClient +from google.cloud.client import _ClientProjectMixin -class Client(object): + +class Client(_BaseClient, _ClientProjectMixin): """Top level Firestore database instance. :type project_id: str - :param project_id: Project containing the Firestore database. + :param project_id: (optional) Project containing the Firestore database. """ def __init__(self, project_id=None): - if project_id is None: - raise ValueError('Missing project id.') - self.project_id = project_id + _ClientProjectMixin.__init__(self, project=project_id) + super(Client, self).__init__() self.database_id = None diff --git a/firestore/unit_tests/test_client.py b/firestore/unit_tests/test_client.py index a91c2d2f69c65..157a7508a0c94 100644 --- a/firestore/unit_tests/test_client.py +++ b/firestore/unit_tests/test_client.py @@ -15,6 +15,8 @@ import unittest +from six import string_types + from google.cloud.firestore import Client @@ -22,9 +24,9 @@ class TestFirestore(unittest.TestCase): """Unit Tests for the google.cloud.firestore.Firestore.""" def test_empty_constructor(self): - with self.assertRaisesRegexp(Exception, 'project id'): - Client() + db = Client() + self.assertIsInstance(db.project, string_types) def test_constructor(self): db = Client('my-project-id') - self.assertIsNotNone(db) + self.assertEqual(db.project, 'my-project-id') From ca014d7f879dda19618b858266cd1ce83b5f4ecc Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Tue, 8 Nov 2016 13:42:19 -0800 Subject: [PATCH 11/12] Back out ClientBase subclassing. --- firestore/google/cloud/firestore/client.py | 15 +++++---------- firestore/unit_tests/test_client.py | 12 +++--------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/firestore/google/cloud/firestore/client.py b/firestore/google/cloud/firestore/client.py index 089a4119e3c53..66c7ae015a940 100644 --- a/firestore/google/cloud/firestore/client.py +++ b/firestore/google/cloud/firestore/client.py @@ -14,18 +14,13 @@ """Firestore database API.""" -from google.cloud.client import Client as _BaseClient -from google.cloud.client import _ClientProjectMixin - -class Client(_BaseClient, _ClientProjectMixin): +class Client(object): """Top level Firestore database instance. - :type project_id: str - :param project_id: (optional) Project containing the Firestore database. + :type project: str + :param project: (optional) Project containing the Firestore database. """ - def __init__(self, project_id=None): - _ClientProjectMixin.__init__(self, project=project_id) - super(Client, self).__init__() - self.database_id = None + def __init__(self, project=None): + raise NotImplementedError() diff --git a/firestore/unit_tests/test_client.py b/firestore/unit_tests/test_client.py index 157a7508a0c94..d6464eff4cb69 100644 --- a/firestore/unit_tests/test_client.py +++ b/firestore/unit_tests/test_client.py @@ -15,18 +15,12 @@ import unittest -from six import string_types - from google.cloud.firestore import Client class TestFirestore(unittest.TestCase): - """Unit Tests for the google.cloud.firestore.Firestore.""" - - def test_empty_constructor(self): - db = Client() - self.assertIsInstance(db.project, string_types) + """Unit Tests for the google.cloud.firestore.Client.""" def test_constructor(self): - db = Client('my-project-id') - self.assertEqual(db.project, 'my-project-id') + with self.assertRaises(NotImplementedError): + Client('my-project-id') From bf4044ff6bfd174827ee5da3d94fd505f657cbd7 Mon Sep 17 00:00:00 2001 From: Mike Koss Date: Tue, 8 Nov 2016 14:00:18 -0800 Subject: [PATCH 12/12] review comments --- firestore/MANIFEST.in | 1 - firestore/google/__init__.py | 1 - firestore/google/cloud/__init__.py | 1 - firestore/google/cloud/firestore/__init__.py | 1 + firestore/google/cloud/firestore/client.py | 4 ++-- firestore/setup.py | 6 +----- firestore/unit_tests/test_client.py | 3 --- 7 files changed, 4 insertions(+), 13 deletions(-) diff --git a/firestore/MANIFEST.in b/firestore/MANIFEST.in index b35b665f32cec..cb3a2b9ef4fa6 100644 --- a/firestore/MANIFEST.in +++ b/firestore/MANIFEST.in @@ -1,5 +1,4 @@ include README.rst graft google graft unit_tests -global-include *.json global-exclude *.pyc diff --git a/firestore/google/__init__.py b/firestore/google/__init__.py index 9cc5be46a3073..b2b8333738826 100644 --- a/firestore/google/__init__.py +++ b/firestore/google/__init__.py @@ -1,4 +1,3 @@ - # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/firestore/google/cloud/__init__.py b/firestore/google/cloud/__init__.py index 9cc5be46a3073..b2b8333738826 100644 --- a/firestore/google/cloud/__init__.py +++ b/firestore/google/cloud/__init__.py @@ -1,4 +1,3 @@ - # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/firestore/google/cloud/firestore/__init__.py b/firestore/google/cloud/firestore/__init__.py index f3003f9324234..940950865ba17 100644 --- a/firestore/google/cloud/firestore/__init__.py +++ b/firestore/google/cloud/firestore/__init__.py @@ -11,6 +11,7 @@ # 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. + """Firestore database API public classes.""" from google.cloud.firestore.client import Client diff --git a/firestore/google/cloud/firestore/client.py b/firestore/google/cloud/firestore/client.py index 66c7ae015a940..baf286d981e9c 100644 --- a/firestore/google/cloud/firestore/client.py +++ b/firestore/google/cloud/firestore/client.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Firestore database API.""" +"""Firestore database SDK Client.""" class Client(object): - """Top level Firestore database instance. + """Firestore Client. :type project: str :param project: (optional) Project containing the Firestore database. diff --git a/firestore/setup.py b/firestore/setup.py index 1822540e0970c..1d3ecd68a37c6 100644 --- a/firestore/setup.py +++ b/firestore/setup.py @@ -50,11 +50,7 @@ } REQUIREMENTS = [ - 'grpcio>=1.0.0, <2.0.0dev', - 'googleapis-common-protos>=1.3.4, <2.0.0dev', - 'google-gax>=0.14.1, <0.15.0dev', - 'oauth2client>=3.0.0, <4.0.0dev', - 'google-cloud-core>=0.20', + 'google-cloud-core >= 0.20', ] setup( diff --git a/firestore/unit_tests/test_client.py b/firestore/unit_tests/test_client.py index d6464eff4cb69..a768e78ff636c 100644 --- a/firestore/unit_tests/test_client.py +++ b/firestore/unit_tests/test_client.py @@ -11,7 +11,6 @@ # 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. -"""Unit tests for Google Firestore SDK.""" import unittest @@ -19,8 +18,6 @@ class TestFirestore(unittest.TestCase): - """Unit Tests for the google.cloud.firestore.Client.""" - def test_constructor(self): with self.assertRaises(NotImplementedError): Client('my-project-id')