コード例 #1
0
 def get_fields(cls):
     return {0: ("enum", protobuf.EnumType("t", (0, 5)), 0)}
コード例 #2
0
 def get_fields(cls):
     return {
         1: ("uintlist", protobuf.UVarintType, protobuf.FLAG_REPEATED),
         2: ("enumlist", protobuf.EnumType("t", (0, 1)), protobuf.FLAG_REPEATED),
         3: ("strlist", protobuf.UnicodeType, protobuf.FLAG_REPEATED),
     }
コード例 #3
0
 def get_fields(cls):
     return {1: ("enum", protobuf.EnumType("t", (0, 1, 2, 3, 4, 5)), 0)}
コード例 #4
0
 def get_fields(cls):
     return {1: ("enum", protobuf.EnumType("t", (0, 5)), None)}
コード例 #5
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.

from unittest.mock import patch
from types import SimpleNamespace

import pytest

from trezorlib import protobuf

SimpleEnum = SimpleNamespace(FOO=0, BAR=5, QUUX=13)
SimpleEnumType = protobuf.EnumType("SimpleEnum", (0, 5, 13))

with_simple_enum = patch("trezorlib.messages.SimpleEnum",
                         SimpleEnum,
                         create=True)


class SimpleMessage(protobuf.MessageType):
    @classmethod
    def get_fields(cls):
        return {
            1: ("uvarint", protobuf.UVarintType, None),
            2: ("svarint", protobuf.SVarintType, None),
            3: ("bool", protobuf.BoolType, None),
            4: ("bytes", protobuf.BytesType, None),
            5: ("unicode", protobuf.UnicodeType, None),