Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/google-cloud-ndb/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +14 to +15

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Globally excluding raise TypeError from coverage reporting is risky. TypeError is commonly raised during input validation, which is a critical part of the public API contract and should be thoroughly unit-tested. Excluding it globally can mask untested validation paths, defeating the purpose of a 100% coverage requirement. If there are specific, untestable defensive type checks, it is safer to exclude them individually using # pragma: no cover rather than ignoring all TypeError exceptions globally.

omit =
.nox/*
*/gapic/*.py
*/proto/*.py
tests/*/*.py
tests/*
*/tests/*
14 changes: 14 additions & 0 deletions packages/google-cloud-ndb/tests/unit/test__gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
14 changes: 14 additions & 0 deletions packages/google-cloud-ndb/tests/unit/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Loading