test_operators.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:graphene-mongo 作者: joaovitorsilvestre 项目源码 文件源码
def test_add_operators_to_field_list_field():
    from mongoengine import ListField, SortedListField
    from graphene_mongo.operators import gen_operators_of_field, allowed_operators
    from graphene_mongo.fields.respective import respective_special_fields, respective_fields

    for m_field in [ListField, SortedListField]:
        for f, r_graphene in respective_fields.items():
            field = m_field(f())

            applied_operators = gen_operators_of_field('test', field, respective_special_fields[m_field],
                                                       allowed_operators(field))

            expected = format_fields(['size'])

            assert len(applied_operators.keys()) == len(expected)
            assert sorted(list(applied_operators.keys())) == sorted(expected)

            obj_list_field = applied_operators['test']('listTest', field)
            assert isinstance(obj_list_field, graphene.List)

            # here we test to assert that the type of items of the list is what is suppose to be
            assert isinstance(obj_list_field.of_type, type(r_graphene))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号