Skip to content

Commit 9ac6bee

Browse files
committed
More tests
1 parent f4bc6a3 commit 9ac6bee

File tree

1 file changed

+39
-47
lines changed

1 file changed

+39
-47
lines changed

graphql/execution/tests/test_tracing.py

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
GraphQLObjectType, GraphQLSchema, GraphQLString)
99

1010

11-
def test_tracing_result(mocker):
11+
def test_tracing(mocker):
1212
time_mock = mocker.patch('time.time')
1313
time_mock.side_effect = range(0, 10000)
1414

@@ -85,8 +85,17 @@ def __init__(self, uid, width, height):
8585
{
8686
feed {
8787
id
88-
title
89-
}
88+
...articleFields
89+
author {
90+
id
91+
name
92+
}
93+
},
94+
}
95+
fragment articleFields on Article {
96+
title,
97+
body,
98+
hidden,
9099
}
91100
'''
92101

@@ -99,62 +108,45 @@ def __init__(self, uid, width, height):
99108
"feed": [
100109
{
101110
"id": "1",
102-
"title": "My Article 1"
111+
"title": "My Article 1",
112+
"body": "This is a post",
113+
"author": {
114+
"id": "123",
115+
"name": "John Smith"
116+
}
103117
},
104118
{
105119
"id": "2",
106-
"title": "My Article 2"
120+
"title": "My Article 2",
121+
"body": "This is a post",
122+
"author": {
123+
"id": "123",
124+
"name": "John Smith"
125+
}
107126
},
108127
],
109128
}
110129

111130
assert result.extensions['tracing'] == {
112131
'version': 1,
113132
'startTime': time.strftime(TracingMiddleware.DATETIME_FORMAT, time.gmtime(0)),
114-
'endTime': time.strftime(TracingMiddleware.DATETIME_FORMAT, time.gmtime(16)),
115-
'duration': 16000,
133+
'endTime': time.strftime(TracingMiddleware.DATETIME_FORMAT, time.gmtime(40)),
134+
'duration': 40000,
116135
'execution': {
117136
'resolvers': [
118-
{
119-
'path': ['feed'],
120-
'parentType': 'Query',
121-
'fieldName': 'feed',
122-
'returnType': '[Article]',
123-
'startOffset': 3000,
124-
'duration': 1000
125-
},
126-
{
127-
'path': ['feed', 0, 'id'],
128-
'parentType': 'Article',
129-
'fieldName': 'id',
130-
'returnType': 'String!',
131-
'startOffset': 6000,
132-
'duration': 1000
133-
},
134-
{
135-
'path': ['feed', 0, 'title'],
136-
'parentType': 'Article',
137-
'fieldName': 'title',
138-
'returnType': 'String',
139-
'startOffset': 9000,
140-
'duration': 1000
141-
},
142-
{
143-
'path': ['feed', 1, 'id'],
144-
'parentType': 'Article',
145-
'fieldName': 'id',
146-
'returnType': 'String!',
147-
'startOffset': 12000,
148-
'duration': 1000
149-
},
150-
{
151-
'path': ['feed', 1, 'title'],
152-
'parentType': 'Article',
153-
'fieldName': 'title',
154-
'returnType': 'String',
155-
'startOffset': 15000,
156-
'duration': 1000
157-
}
137+
{'path': ['feed'], 'parentType': 'Query', 'fieldName': 'feed', 'returnType': '[Article]', 'startOffset': 3000, 'duration': 1000},
138+
{'path': ['feed', 0, 'id'], 'parentType': 'Article', 'fieldName': 'id', 'returnType': 'String!', 'startOffset': 6000, 'duration': 1000},
139+
{'path': ['feed', 0, 'title'], 'parentType': 'Article', 'fieldName': 'title', 'returnType': 'String', 'startOffset': 9000, 'duration': 1000},
140+
{'path': ['feed', 0, 'body'], 'parentType': 'Article', 'fieldName': 'body', 'returnType': 'String', 'startOffset': 12000, 'duration': 1000},
141+
{'path': ['feed', 0, 'author'], 'parentType': 'Article', 'fieldName': 'author', 'returnType': 'Author', 'startOffset': 15000, 'duration': 1000},
142+
{'path': ['feed', 1, 'id'], 'parentType': 'Article', 'fieldName': 'id', 'returnType': 'String!', 'startOffset': 18000, 'duration': 1000},
143+
{'path': ['feed', 1, 'title'], 'parentType': 'Article', 'fieldName': 'title', 'returnType': 'String', 'startOffset': 21000, 'duration': 1000},
144+
{'path': ['feed', 1, 'body'], 'parentType': 'Article', 'fieldName': 'body', 'returnType': 'String', 'startOffset': 24000, 'duration': 1000},
145+
{'path': ['feed', 1, 'author'], 'parentType': 'Article', 'fieldName': 'author', 'returnType': 'Author', 'startOffset': 27000, 'duration': 1000},
146+
{'path': ['feed', 0, 'author', 'id'], 'parentType': 'Author', 'fieldName': 'id', 'returnType': 'String', 'startOffset': 30000, 'duration': 1000},
147+
{'path': ['feed', 0, 'author', 'name'], 'parentType': 'Author', 'fieldName': 'name', 'returnType': 'String', 'startOffset': 33000, 'duration': 1000},
148+
{'path': ['feed', 1, 'author', 'id'], 'parentType': 'Author', 'fieldName': 'id', 'returnType': 'String', 'startOffset': 36000, 'duration': 1000},
149+
{'path': ['feed', 1, 'author', 'name'], 'parentType': 'Author', 'fieldName': 'name', 'returnType': 'String', 'startOffset': 39000, 'duration': 1000}
158150
]
159151
}
160152
}

0 commit comments

Comments
 (0)