Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: constructor invalid path tests #114

Merged
merged 4 commits into from Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions tests/unit/v1/test_async_collection.py
Expand Up @@ -79,20 +79,6 @@ def test_constructor(self):
expected_path = (collection_id1, document_id, collection_id2)
self.assertEqual(collection._path, expected_path)

def test_constructor_invalid_path(self):
with self.assertRaises(ValueError):
self._make_one()
with self.assertRaises(ValueError):
self._make_one(99, "doc", "bad-collection-id")
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None, "sub-collection")
with self.assertRaises(ValueError):
self._make_one("Just", "A-Document")

def test_constructor_invalid_kwarg(self):
with self.assertRaises(TypeError):
self._make_one("Coh-lek-shun", donut=True)

@pytest.mark.asyncio
async def test_add_auto_assigned(self):
from google.cloud.firestore_v1.types import document
Expand Down
14 changes: 0 additions & 14 deletions tests/unit/v1/test_async_document.py
Expand Up @@ -47,20 +47,6 @@ def test_constructor(self):
)
self.assertEqual(document.path, expected_path)

def test_constructor_invalid_path(self):
with self.assertRaises(ValueError):
self._make_one()
with self.assertRaises(ValueError):
self._make_one(None, "before", "bad-collection-id", "fifteen")
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None)
with self.assertRaises(ValueError):
self._make_one("Just", "A-Collection", "Sub")

def test_constructor_invalid_kwarg(self):
with self.assertRaises(TypeError):
self._make_one("Coh-lek-shun", "Dahk-yu-mehnt", burger=18.75)

@staticmethod
def _make_commit_repsonse(write_results=None):
from google.cloud.firestore_v1.types import firestore
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/v1/test_async_query.py
Expand Up @@ -32,7 +32,7 @@ def _make_one(self, *args, **kwargs):
klass = self._get_target_class()
return klass(*args, **kwargs)

def test_constructor_defaults(self):
def test_constructor(self):
query = self._make_one(mock.sentinel.parent)
self.assertIs(query._parent, mock.sentinel.parent)
self.assertIsNone(query._projection)
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/v1/test_base_collection.py
Expand Up @@ -41,13 +41,19 @@ def test_constructor(self):
expected_path = (collection_id1, document_id, collection_id2)
self.assertEqual(collection._path, expected_path)

def test_constructor_invalid_path(self):
def test_constructor_invalid_path_empty(self):
with self.assertRaises(ValueError):
self._make_one()

def test_constructor_invalid_path_bad_collection_id(self):
with self.assertRaises(ValueError):
self._make_one(99, "doc", "bad-collection-id")

def test_constructor_invalid_path_bad_document_id(self):
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None, "sub-collection")

def test_constructor_invalid_path_bad_number_args(self):
with self.assertRaises(ValueError):
self._make_one("Just", "A-Document")

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/v1/test_base_document.py
Expand Up @@ -47,13 +47,19 @@ def test_constructor(self):
)
self.assertEqual(document.path, expected_path)

def test_constructor_invalid_path(self):
def test_constructor_invalid_path_empty(self):
with self.assertRaises(ValueError):
self._make_one()

def test_constructor_invalid_path_bad_collection_id(self):
with self.assertRaises(ValueError):
self._make_one(None, "before", "bad-collection-id", "fifteen")

def test_constructor_invalid_path_bad_document_id(self):
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None)

def test_constructor_invalid_path_bad_number_args(self):
with self.assertRaises(ValueError):
self._make_one("Just", "A-Collection", "Sub")

Expand Down
14 changes: 0 additions & 14 deletions tests/unit/v1/test_collection.py
Expand Up @@ -68,20 +68,6 @@ def test_constructor(self):
expected_path = (collection_id1, document_id, collection_id2)
self.assertEqual(collection._path, expected_path)

def test_constructor_invalid_path(self):
with self.assertRaises(ValueError):
self._make_one()
with self.assertRaises(ValueError):
self._make_one(99, "doc", "bad-collection-id")
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None, "sub-collection")
with self.assertRaises(ValueError):
self._make_one("Just", "A-Document")

def test_constructor_invalid_kwarg(self):
with self.assertRaises(TypeError):
self._make_one("Coh-lek-shun", donut=True)

def test_add_auto_assigned(self):
from google.cloud.firestore_v1.types import document
from google.cloud.firestore_v1.document import DocumentReference
Expand Down
14 changes: 0 additions & 14 deletions tests/unit/v1/test_document.py
Expand Up @@ -46,20 +46,6 @@ def test_constructor(self):
)
self.assertEqual(document.path, expected_path)

def test_constructor_invalid_path(self):
with self.assertRaises(ValueError):
self._make_one()
with self.assertRaises(ValueError):
self._make_one(None, "before", "bad-collection-id", "fifteen")
with self.assertRaises(ValueError):
self._make_one("bad-document-ID", None)
with self.assertRaises(ValueError):
self._make_one("Just", "A-Collection", "Sub")

def test_constructor_invalid_kwarg(self):
with self.assertRaises(TypeError):
self._make_one("Coh-lek-shun", "Dahk-yu-mehnt", burger=18.75)

@staticmethod
def _make_commit_repsonse(write_results=None):
from google.cloud.firestore_v1.types import firestore
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/v1/test_query.py
Expand Up @@ -31,7 +31,7 @@ def _make_one(self, *args, **kwargs):
klass = self._get_target_class()
return klass(*args, **kwargs)

def test_constructor_defaults(self):
def test_constructor(self):
query = self._make_one(mock.sentinel.parent)
self.assertIs(query._parent, mock.sentinel.parent)
self.assertIsNone(query._projection)
Expand Down