【发布时间】:2020-04-22 19:15:09
【问题描述】:
我正在使用
from graphene_django.utils.testing import GraphQLTestCase
实现我的测试。但是,来自
的结果class PeopleTests(GraphQLTestCase):
GRAPHQL_SCHEMA = schema
def test_all_person_query_admin_token(self):
response = self.query(
'''
query getPersons{
persons{
firstName,
lastName
}
}
''',
op_name='persons',
headers={'HTTP_AUTHORIZATION': f'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNTY2MTk4Mzg5LCJvcmlnSWF0IjoxNTY2MTk4MDg5fQ.P4u7PNKPLFsc4dvhBLw-EfuN8jg2d-lqdZjWruEDlpc'}
)
总是返回一个空的 Person 列表。我在Django Test Database looks empty while test is runnin 中读到这是 GraphQLTestCase 继承自 TestCase 的结果。这篇文章很旧(2012 年),但我似乎找不到任何关于如何使用合适的测试数据库的文档。
对不起,如果我错过了什么,答案很明显。
谢谢
【问题讨论】:
标签: python django unit-testing graphene-python graphene-django