56
56
_django_instrumentor = DjangoInstrumentor ()
57
57
58
58
59
- @pytest .mark .skipif (not DJANGO_3_1 , reason = "AsyncClient implemented since Django 3.1" )
59
+ @pytest .mark .skipif (
60
+ not DJANGO_3_1 , reason = "AsyncClient implemented since Django 3.1"
61
+ )
60
62
class TestMiddlewareAsgi (SimpleTestCase , TestBase ):
61
-
62
63
@classmethod
63
64
def setUpClass (cls ):
64
65
super ().setUpClass ()
@@ -110,7 +111,6 @@ def _remove_databases_failures(cls):
110
111
# Disable databases.
111
112
pass
112
113
113
- @pytest .mark .skip (reason = "TODO" )
114
114
async def test_templated_route_get (self ):
115
115
await self .async_client .get ("/route/2020/template/" )
116
116
@@ -125,17 +125,17 @@ async def test_templated_route_get(self):
125
125
self .assertEqual (span .attributes ["http.method" ], "GET" )
126
126
self .assertEqual (
127
127
span .attributes ["http.url" ],
128
- "http://testserver /route/2020/template/" ,
128
+ "http://127.0.0.1 /route/2020/template/" ,
129
129
)
130
130
self .assertEqual (
131
131
span .attributes ["http.route" ],
132
132
"^route/(?P<year>[0-9]{4})/template/$" ,
133
133
)
134
134
self .assertEqual (span .attributes ["http.scheme" ], "http" )
135
135
self .assertEqual (span .attributes ["http.status_code" ], 200 )
136
- self .assertEqual (span .attributes ["http.status_text" ], "OK" )
136
+ # TODO: Add http.status_text to ASGI instrumentation.
137
+ # self.assertEqual(span.attributes["http.status_text"], "OK")
137
138
138
- @pytest .mark .skip (reason = "TODO" )
139
139
async def test_traced_get (self ):
140
140
await self .async_client .get ("/traced/" )
141
141
@@ -149,12 +149,13 @@ async def test_traced_get(self):
149
149
self .assertEqual (span .status .status_code , StatusCode .UNSET )
150
150
self .assertEqual (span .attributes ["http.method" ], "GET" )
151
151
self .assertEqual (
152
- span .attributes ["http.url" ], "http://testserver /traced/"
152
+ span .attributes ["http.url" ], "http://127.0.0.1 /traced/"
153
153
)
154
154
self .assertEqual (span .attributes ["http.route" ], "^traced/" )
155
155
self .assertEqual (span .attributes ["http.scheme" ], "http" )
156
156
self .assertEqual (span .attributes ["http.status_code" ], 200 )
157
- self .assertEqual (span .attributes ["http.status_text" ], "OK" )
157
+ # TODO: Add http.status_text to ASGI instrumentation.
158
+ # self.assertEqual(span.attributes["http.status_text"], "OK")
158
159
159
160
async def test_not_recording (self ):
160
161
mock_tracer = Mock ()
@@ -169,7 +170,6 @@ async def test_not_recording(self):
169
170
self .assertFalse (mock_span .set_attribute .called )
170
171
self .assertFalse (mock_span .set_status .called )
171
172
172
- @pytest .mark .skip (reason = "TODO" )
173
173
async def test_traced_post (self ):
174
174
await self .async_client .post ("/traced/" )
175
175
@@ -183,14 +183,14 @@ async def test_traced_post(self):
183
183
self .assertEqual (span .status .status_code , StatusCode .UNSET )
184
184
self .assertEqual (span .attributes ["http.method" ], "POST" )
185
185
self .assertEqual (
186
- span .attributes ["http.url" ], "http://testserver /traced/"
186
+ span .attributes ["http.url" ], "http://127.0.0.1 /traced/"
187
187
)
188
188
self .assertEqual (span .attributes ["http.route" ], "^traced/" )
189
189
self .assertEqual (span .attributes ["http.scheme" ], "http" )
190
190
self .assertEqual (span .attributes ["http.status_code" ], 200 )
191
- self .assertEqual (span .attributes ["http.status_text" ], "OK" )
191
+ # TODO: Add http.status_text to ASGI instrumentation.
192
+ # self.assertEqual(span.attributes["http.status_text"], "OK")
192
193
193
- @pytest .mark .skip (reason = "TODO" )
194
194
async def test_error (self ):
195
195
with self .assertRaises (ValueError ):
196
196
await self .async_client .get ("/error/" )
@@ -205,7 +205,7 @@ async def test_error(self):
205
205
self .assertEqual (span .status .status_code , StatusCode .ERROR )
206
206
self .assertEqual (span .attributes ["http.method" ], "GET" )
207
207
self .assertEqual (
208
- span .attributes ["http.url" ], "http://testserver /error/"
208
+ span .attributes ["http.url" ], "http://127.0.0.1 /error/"
209
209
)
210
210
self .assertEqual (span .attributes ["http.route" ], "^error/" )
211
211
self .assertEqual (span .attributes ["http.scheme" ], "http" )
@@ -262,7 +262,7 @@ async def test_span_name_404(self):
262
262
span = span_list [0 ]
263
263
self .assertEqual (span .name , "HTTP GET" )
264
264
265
- @pytest .mark .skip (reason = "TODO" )
265
+ @pytest .mark .skip (reason = "TODO: Traced request attributes not supported yet. " )
266
266
async def test_traced_request_attrs (self ):
267
267
await self .async_client .get ("/span_name/1234/" , CONTENT_TYPE = "test/ct" )
268
268
span_list = self .memory_exporter .get_finished_spans ()
0 commit comments