Skip to content

Commit

Permalink
Merge pull request googleapis#164 from jgeewax/koss-hide-path
Browse files Browse the repository at this point in the history
Hide Path from the Firestore API.
  • Loading branch information
mckoss authored Jan 5, 2017
2 parents a0c9f7f + 5c310bb commit e6f384c
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 27 deletions.
5 changes: 0 additions & 5 deletions docs/firestore-path.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
firestore-client
firestore-collection
firestore-document
firestore-path

.. toctree::
:maxdepth: 0
Expand Down
2 changes: 0 additions & 2 deletions firestore/google/cloud/firestore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
from google.cloud.firestore.client import Client
from google.cloud.firestore.collection import CollectionRef
from google.cloud.firestore.document import Document
from google.cloud.firestore.path import Path


__all__ = [
'Client',
'Path',
'Document',
'CollectionRef',
]
File renamed without changes.
8 changes: 4 additions & 4 deletions firestore/google/cloud/firestore/_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import datetime

from google.cloud.firestore import document
from google.cloud.firestore import path
from google.cloud.firestore import _path

import six

Expand All @@ -39,7 +39,7 @@ def encode_value(val):
:type val: str, unicode, int, bool, float, datetime.datetime, bytes,
dict, None,
:class:`google.cloud.firestore.Path`, or
:class:`google.cloud.firestore._path.Path`, or
:class:`google.cloud.firestore.Document`.
:param val: A native Python value.
Expand Down Expand Up @@ -69,7 +69,7 @@ def encode_value(val):
if isinstance(val, six.binary_type):
return Value(blob_value=val)

if isinstance(val, path.Path):
if isinstance(val, _path.Path):
if val.is_empty:
return encode_value(None)

Expand Down Expand Up @@ -101,7 +101,7 @@ def decode_value(val):
:rtype: str, unicode, int, bool, float, datetime.datetime, bytes,
dict, None,
:class:`google.cloud.firestore.Path`, or
:class:`google.cloud.firestore._path.Path`, or
:class:`google.cloud.firestore.Document`.
:returns: A native Python value.
"""
Expand Down
2 changes: 1 addition & 1 deletion firestore/unit_tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _make_one(self, *args, **kwargs):
return self._get_target_class()(*args, **kwargs)

def test_constructor(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

client = object()
path = Path('my-collection')
Expand Down
14 changes: 5 additions & 9 deletions firestore/unit_tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _get_target_class():
return Document

def _make_one(self, client, path=None, properties=None, *args, **kwargs):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

if path is None:
path = Path('my-collection', 'my-document')
Expand All @@ -33,7 +33,7 @@ def _make_one(self, client, path=None, properties=None, *args, **kwargs):
*args, **kwargs)

def test_constructor(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

client = object()
properties = {'hi': 'mom'}
Expand All @@ -46,21 +46,17 @@ def test_constructor(self):
self.assertEqual(dict(doc), properties)

def test_constructor_path_non_document(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

client = object()
collection_path = Path('my-collection')
with self.assertRaisesRegexp(ValueError, 'Invalid'):
self._make_one(client, collection_path)

def test_doc_id(self):
from google.cloud.firestore.path import Path

client = object()
doc_id = 'my-document'
path = Path('my-collection', doc_id)
doc = self._make_one(client, path)
self.assertEqual(doc.doc_id, doc_id)
doc = self._make_one(client)
self.assertEqual(doc.doc_id, 'my-document')

def test_version(self):
client = object()
Expand Down
8 changes: 4 additions & 4 deletions firestore/unit_tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestPath(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path
return Path

def _make_one(self, *args, **kwargs):
Expand Down Expand Up @@ -129,23 +129,23 @@ def test_nested_document_to_key_proto(self):
self.assertEqual(key.path[1].name, 'nested-doc')

def test_document_name_from_proto(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

path = self._make_one('my-collection', 'my-document')
key = path.to_key_proto()
path_from_key = Path.from_key_proto(key)
self.assertEqual(path, path_from_key)

def test_document_id_from_proto(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

path = self._make_one('my-collection', 123)
key = path.to_key_proto()
path_from_key = Path.from_key_proto(key)
self.assertEqual(path, path_from_key)

def test_collection_from_proto(self):
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

path = self._make_one('my-collection')
key = path.to_key_proto()
Expand Down
2 changes: 1 addition & 1 deletion firestore/unit_tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_blob(self):
def test_path(self):
from google.protobuf import struct_pb2
from google.firestore.v1alpha1.entity_pb2 import Key
from google.cloud.firestore.path import Path
from google.cloud.firestore._path import Path

empty_path = Path()

Expand Down

0 comments on commit e6f384c

Please sign in to comment.