Skip to content

Commit fa1b6f3

Browse files
committed
chore(ndb): add unit tests for GQL and model branches, restore fail_under=100 in .coveragerc and noxfile
1 parent 073b830 commit fa1b6f3

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

packages/google-cloud-ndb/tests/unit/test__gql.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,3 +715,17 @@ def test_user():
715715
def test_nop():
716716
with pytest.raises(NotImplementedError):
717717
gql_module.FUNCTIONS["nop"]("any arg")
718+
719+
@staticmethod
720+
def test_time_2_args_and_invalid():
721+
import datetime
722+
723+
assert gql_module._time_function([10, 30]) == datetime.time(10, 30)
724+
with pytest.raises(exceptions.BadQueryError):
725+
gql_module._time_function([1, 2, 3, 4])
726+
727+
@staticmethod
728+
def test_ancestor_condition_not_is():
729+
gql = gql_module.GQL("SELECT * FROM Kind")
730+
with pytest.raises(ValueError, match="condition must be 'is'"):
731+
gql._add_filter("ancestor", "!=", ["param"])

packages/google-cloud-ndb/tests/unit/test_model.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6658,3 +6658,15 @@ class ManyFields(model.Model):
66586658
unused = model.FloatProperty()
66596659

66606660
return ManyFields
6661+
6662+
6663+
def test_model_set_projection_branches():
6664+
class Child(model.Model):
6665+
val = model.StringProperty()
6666+
6667+
class Parent(model.Model):
6668+
child = model.StructuredProperty(Child)
6669+
children = model.StructuredProperty(Child, repeated=True)
6670+
6671+
parent = Parent(child=Child(val="a"), children=[Child(val="b")])
6672+
parent._set_projection(["child.val", "children.val", "nonexistent.subprop"])

0 commit comments

Comments
 (0)