示例#1
0
    def test_should_return_correct_list_for_array():
        # given (see above)

        # when
        path_field_names = accessors.path_seq(Message.recipients.e.full_name)

        # then
        assert path_field_names == ["recipients", "full_name"]
示例#2
0
    def test_should_return_correct_list_for_nested_schema():
        # given (see above)

        # when
        path_field_names = accessors.path_seq(Article.author.full_name)

        # then
        assert path_field_names == ["author", "full_name"]
示例#3
0
    def test_should_return_correct_list_for_nested_array_with_explicit_field_name(
    ):
        # given (see above)
        class Element(Struct):
            element_field = String(name="alt_element_field_name",
                                   nullable=True)

        class StructWithArray(Struct):
            array_field = Array(Element(),
                                name="alt_array_field_name",
                                nullable=True)

        # when
        path_field_names = accessors.path_seq(
            StructWithArray.array_field.e.element_field)

        # then
        assert path_field_names == [
            "alt_array_field_name", "alt_element_field_name"
        ]