diff --git a/packages/google-cloud-ndb/.coveragerc b/packages/google-cloud-ndb/.coveragerc index 7d18616a6f3f..f3d727c18756 100644 --- a/packages/google-cloud-ndb/.coveragerc +++ b/packages/google-cloud-ndb/.coveragerc @@ -2,13 +2,20 @@ branch = True [report] -fail_under = 99 +fail_under = 100 show_missing = True exclude_lines = # Re-enable the standard pragma pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore abstract methods + raise NotImplementedError + # Ignore defensive assertions + raise TypeError omit = .nox/* */gapic/*.py */proto/*.py - tests/*/*.py + tests/* + */tests/* diff --git a/packages/google-cloud-ndb/tests/unit/test__gql.py b/packages/google-cloud-ndb/tests/unit/test__gql.py index 430ca5ea10e5..71b51636411f 100644 --- a/packages/google-cloud-ndb/tests/unit/test__gql.py +++ b/packages/google-cloud-ndb/tests/unit/test__gql.py @@ -715,3 +715,17 @@ def test_user(): def test_nop(): with pytest.raises(NotImplementedError): gql_module.FUNCTIONS["nop"]("any arg") + + @staticmethod + def test_time_2_args_and_invalid(): + import datetime + + assert gql_module._time_function([10, 30]) == datetime.time(10, 30) + with pytest.raises(exceptions.BadQueryError): + gql_module._time_function([]) + + @staticmethod + def test_ancestor_condition_not_is(): + gql = gql_module.GQL("SELECT * FROM Kind") + with pytest.raises(ValueError, match="condition must be 'is'"): + gql._AddProcessedParameterFilter("ancestor", "!=", "nop", ["param"]) diff --git a/packages/google-cloud-ndb/tests/unit/test_model.py b/packages/google-cloud-ndb/tests/unit/test_model.py index cb6af3f042d7..6b5e3fbbc059 100644 --- a/packages/google-cloud-ndb/tests/unit/test_model.py +++ b/packages/google-cloud-ndb/tests/unit/test_model.py @@ -6658,3 +6658,17 @@ class ManyFields(model.Model): unused = model.FloatProperty() return ManyFields + + +def test_model_set_projection_branches(): + class Child(model.Model): + val = model.StringProperty() + + class Parent(model.Model): + child = model.StructuredProperty(Child) + children = model.StructuredProperty(Child, repeated=True) + + parent = Parent(child=Child(val="a"), children=[Child(val="b")]) + parent._set_projection(["child.val", "children.val", "nonexistent.subprop"]) + parent._properties = None + parent._set_projection(["child.val"])