Skip to content

Commit edf7bd1

Browse files
authored
fix: constructor invalid path tests (#114)
* fix: query constructor test naming * fix: remove duplicate document tests * fix: remove duplicate collection tests * refactor: split invalid path tests
1 parent 6e597f2 commit edf7bd1

File tree

8 files changed

+16
-60
lines changed

8 files changed

+16
-60
lines changed

tests/unit/v1/test_async_collection.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,6 @@ def test_constructor(self):
7979
expected_path = (collection_id1, document_id, collection_id2)
8080
self.assertEqual(collection._path, expected_path)
8181

82-
def test_constructor_invalid_path(self):
83-
with self.assertRaises(ValueError):
84-
self._make_one()
85-
with self.assertRaises(ValueError):
86-
self._make_one(99, "doc", "bad-collection-id")
87-
with self.assertRaises(ValueError):
88-
self._make_one("bad-document-ID", None, "sub-collection")
89-
with self.assertRaises(ValueError):
90-
self._make_one("Just", "A-Document")
91-
92-
def test_constructor_invalid_kwarg(self):
93-
with self.assertRaises(TypeError):
94-
self._make_one("Coh-lek-shun", donut=True)
95-
9682
@pytest.mark.asyncio
9783
async def test_add_auto_assigned(self):
9884
from google.cloud.firestore_v1.types import document

tests/unit/v1/test_async_document.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ def test_constructor(self):
4747
)
4848
self.assertEqual(document.path, expected_path)
4949

50-
def test_constructor_invalid_path(self):
51-
with self.assertRaises(ValueError):
52-
self._make_one()
53-
with self.assertRaises(ValueError):
54-
self._make_one(None, "before", "bad-collection-id", "fifteen")
55-
with self.assertRaises(ValueError):
56-
self._make_one("bad-document-ID", None)
57-
with self.assertRaises(ValueError):
58-
self._make_one("Just", "A-Collection", "Sub")
59-
60-
def test_constructor_invalid_kwarg(self):
61-
with self.assertRaises(TypeError):
62-
self._make_one("Coh-lek-shun", "Dahk-yu-mehnt", burger=18.75)
63-
6450
@staticmethod
6551
def _make_commit_repsonse(write_results=None):
6652
from google.cloud.firestore_v1.types import firestore

tests/unit/v1/test_async_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _make_one(self, *args, **kwargs):
3232
klass = self._get_target_class()
3333
return klass(*args, **kwargs)
3434

35-
def test_constructor_defaults(self):
35+
def test_constructor(self):
3636
query = self._make_one(mock.sentinel.parent)
3737
self.assertIs(query._parent, mock.sentinel.parent)
3838
self.assertIsNone(query._projection)

tests/unit/v1/test_base_collection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ def test_constructor(self):
4141
expected_path = (collection_id1, document_id, collection_id2)
4242
self.assertEqual(collection._path, expected_path)
4343

44-
def test_constructor_invalid_path(self):
44+
def test_constructor_invalid_path_empty(self):
4545
with self.assertRaises(ValueError):
4646
self._make_one()
47+
48+
def test_constructor_invalid_path_bad_collection_id(self):
4749
with self.assertRaises(ValueError):
4850
self._make_one(99, "doc", "bad-collection-id")
51+
52+
def test_constructor_invalid_path_bad_document_id(self):
4953
with self.assertRaises(ValueError):
5054
self._make_one("bad-document-ID", None, "sub-collection")
55+
56+
def test_constructor_invalid_path_bad_number_args(self):
5157
with self.assertRaises(ValueError):
5258
self._make_one("Just", "A-Document")
5359

tests/unit/v1/test_base_document.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ def test_constructor(self):
4747
)
4848
self.assertEqual(document.path, expected_path)
4949

50-
def test_constructor_invalid_path(self):
50+
def test_constructor_invalid_path_empty(self):
5151
with self.assertRaises(ValueError):
5252
self._make_one()
53+
54+
def test_constructor_invalid_path_bad_collection_id(self):
5355
with self.assertRaises(ValueError):
5456
self._make_one(None, "before", "bad-collection-id", "fifteen")
57+
58+
def test_constructor_invalid_path_bad_document_id(self):
5559
with self.assertRaises(ValueError):
5660
self._make_one("bad-document-ID", None)
61+
62+
def test_constructor_invalid_path_bad_number_args(self):
5763
with self.assertRaises(ValueError):
5864
self._make_one("Just", "A-Collection", "Sub")
5965

tests/unit/v1/test_collection.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,6 @@ def test_constructor(self):
6868
expected_path = (collection_id1, document_id, collection_id2)
6969
self.assertEqual(collection._path, expected_path)
7070

71-
def test_constructor_invalid_path(self):
72-
with self.assertRaises(ValueError):
73-
self._make_one()
74-
with self.assertRaises(ValueError):
75-
self._make_one(99, "doc", "bad-collection-id")
76-
with self.assertRaises(ValueError):
77-
self._make_one("bad-document-ID", None, "sub-collection")
78-
with self.assertRaises(ValueError):
79-
self._make_one("Just", "A-Document")
80-
81-
def test_constructor_invalid_kwarg(self):
82-
with self.assertRaises(TypeError):
83-
self._make_one("Coh-lek-shun", donut=True)
84-
8571
def test_add_auto_assigned(self):
8672
from google.cloud.firestore_v1.types import document
8773
from google.cloud.firestore_v1.document import DocumentReference

tests/unit/v1/test_document.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ def test_constructor(self):
4646
)
4747
self.assertEqual(document.path, expected_path)
4848

49-
def test_constructor_invalid_path(self):
50-
with self.assertRaises(ValueError):
51-
self._make_one()
52-
with self.assertRaises(ValueError):
53-
self._make_one(None, "before", "bad-collection-id", "fifteen")
54-
with self.assertRaises(ValueError):
55-
self._make_one("bad-document-ID", None)
56-
with self.assertRaises(ValueError):
57-
self._make_one("Just", "A-Collection", "Sub")
58-
59-
def test_constructor_invalid_kwarg(self):
60-
with self.assertRaises(TypeError):
61-
self._make_one("Coh-lek-shun", "Dahk-yu-mehnt", burger=18.75)
62-
6349
@staticmethod
6450
def _make_commit_repsonse(write_results=None):
6551
from google.cloud.firestore_v1.types import firestore

tests/unit/v1/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _make_one(self, *args, **kwargs):
3131
klass = self._get_target_class()
3232
return klass(*args, **kwargs)
3333

34-
def test_constructor_defaults(self):
34+
def test_constructor(self):
3535
query = self._make_one(mock.sentinel.parent)
3636
self.assertIs(query._parent, mock.sentinel.parent)
3737
self.assertIsNone(query._projection)

0 commit comments

Comments
 (0)