Did I find the right examples for you? yes no

All Samples(7)  |  Call(7)  |  Derive(0)  |  Import(0)

src/r/a/Rammbock-HEAD/utest/test_templates/test_message_templates.py   Rammbock(Download)
    def test_validate_struct_fails(self):
        template = get_pair()
        field = template.encode({})
        self._should_fail(template.validate({'pair': field}, {'pair.first': '42'}), 1)
 
    def test_validate_list_fails(self):
        template = get_list_of_three()
        encoded = template.encode({}, None)
        self._should_fail(template.validate({'topthree': encoded}, {'topthree[1]': '42'}), 1)
 
    def test_validate_list_list(self):
        template = get_list_list()
        encoded = template.encode({}, None)
        self._should_pass(template.validate({'listlist': encoded}, {'listlist[1][1]': '7'}))
        self._should_fail(template.validate({'listlist': encoded}, {'listlist[1][1]': '42'}), 1)
    def test_validate_struct_list(self):
        template = get_struct_list()
        encoded = template.encode({}, None)
        self._should_pass(template.validate({'liststruct': encoded}, {'liststruct[1].first': '1'}))
        self._should_fail(template.validate({'liststruct': encoded}, {'liststruct[1].first': '42'}), 1)
        encoded = struct.encode({'foo.len': 6, 'foo.text': 'fobba'})
        self._should_pass(struct.validate({'foo': encoded}, {'foo.text': 'fobba'}))
        self._should_fail(struct.validate({'foo': encoded}, {'foo.text': 'fob'}), 1)
 
 

src/r/a/Rammbock-HEAD/utest/test_templates/test_unions.py   Rammbock(Download)
    def test_validate_union(self):
        union = self._get_foo_union()
        decoded = union.decode(to_bin('0xcafebabe'))
        self._should_pass(union.validate({'foo': decoded}, {'foo.small': '', 'foo.medium': ''}))
        self._should_fail(union.validate({'foo': decoded}, {'foo.small': '0xff', 'foo.medium': ''}), 1)
        struct.add(union)
        decoded = struct.decode(to_bin('0xcafebabe f00dd00d'))
        self._should_fail(struct.validate({'pair': decoded}, {}), 3)