1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import pytest
pytestmark = pytest.mark.asyncio
@pytest.fixture
def query(schema):
async def query(query):
return await schema.execute(query)
return query
@pytest.mark.django_db(transaction=True)
async def test_query(query, user, group, tag):
result = await query("{ users { id name group { id name tags { id name } } } }")
assert not result.errors
assert result.data["users"] == [
{
"id": str(user.id),
"name": "user",
"group": {
"id": str(group.id),
"name": "group",
"tags": [
{
"id": str(tag.id),
"name": "tag",
},
],
},
},
]
|