userver: testsuite.protobuf.matching.PartialProtobufDict Class Reference
Loading...
Searching...
No Matches
testsuite.protobuf.matching.PartialProtobufDict Class Reference

Detailed Description

Partial protobuf matcher.

Compares a protobuf message against an expected dict by converting the message via :py:func:testsuite.protobuf.utils.message_to_dict and delegating to :py:class:testsuite.matching.PartialDict. Only the keys listed in the expected dict are checked; any additional fields on the protobuf message are ignored.

The match is only partial at the top level: nested dicts in the expected pattern still have to equal the corresponding nested message dicts exactly. Use :py:class:RecursivePartialProtobufDict when nested messages should also be matched partially.

Example:

.. code-block:: python

Passes regardless of other fields set on msg

assert msg == matching.PartialProtobufDict({'first_name': 'John'})

Definition at line 54 of file matching.py.

Inheritance diagram for testsuite.protobuf.matching.PartialProtobufDict:

Public Member Functions

 __init__ (self, d)
 __repr__ (self)
 __eq__ (self, other)

Protected Attributes

 _repr = repr
 _impl = impl

Constructor & Destructor Documentation

◆ __init__()

testsuite.protobuf.matching.PartialProtobufDict.__init__ ( self,
d )

Definition at line 76 of file matching.py.

Member Function Documentation

◆ __eq__()

testsuite.protobuf.matching.ProtobufDictsImpl.__eq__ ( self,
other )
inherited

Definition at line 17 of file matching.py.

◆ __repr__()

testsuite.protobuf.matching.ProtobufDictsImpl.__repr__ ( self)
inherited

Definition at line 14 of file matching.py.

Member Data Documentation

◆ _impl

testsuite.protobuf.matching.ProtobufDictsImpl._impl = impl
protectedinherited

Definition at line 12 of file matching.py.

◆ _repr

testsuite.protobuf.matching.ProtobufDictsImpl._repr = repr
protectedinherited

Definition at line 11 of file matching.py.


The documentation for this class was generated from the following file: