@@ -295,7 +295,7 @@ def setUp(self):
295
295
setup_testing_defaults (self .scope )
296
296
self .span = mock .create_autospec (trace_api .Span , spec_set = True )
297
297
298
- def test_query_string_utf8 (self ):
298
+ def test_request_attributes (self ):
299
299
self .scope ["query_string" ] = b"foo=bar"
300
300
301
301
attrs = otel_asgi .collect_request_attributes (self .scope )
@@ -315,25 +315,20 @@ def test_query_string_utf8(self):
315
315
},
316
316
)
317
317
318
- def test_query_string_percent_encoding (self ):
319
- self .scope ["query_string" ] = urllib .parse .quote (b"foo=bar" )
318
+ def test_query_string (self ):
319
+ self .scope ["query_string" ] = b"foo=bar"
320
+ attrs = otel_asgi .collect_request_attributes (self .scope )
321
+ self .assertEqual (attrs ["http.url" ], "http://127.0.0.1/?foo=bar" )
320
322
323
+ def test_query_string_percent_bytes (self ):
324
+ self .scope ["query_string" ] = b"foo%3Dbar"
321
325
attrs = otel_asgi .collect_request_attributes (self .scope )
322
- self .assertDictEqual (
323
- attrs ,
324
- {
325
- "component" : "http" ,
326
- "http.method" : "GET" ,
327
- "http.host" : "127.0.0.1" ,
328
- "http.target" : "/" ,
329
- "http.url" : "http://127.0.0.1/?foo=bar" ,
330
- "host.port" : 80 ,
331
- "http.scheme" : "http" ,
332
- "http.flavor" : "1.0" ,
333
- "net.peer.ip" : "127.0.0.1" ,
334
- "net.peer.port" : 32767 ,
335
- },
336
- )
326
+ self .assertEqual (attrs ["http.url" ], "http://127.0.0.1/?foo=bar" )
327
+
328
+ def test_query_string_percent_str (self ):
329
+ self .scope ["query_string" ] = "foo%3Dbar"
330
+ attrs = otel_asgi .collect_request_attributes (self .scope )
331
+ self .assertEqual (attrs ["http.url" ], "http://127.0.0.1/?foo=bar" )
337
332
338
333
def test_response_attributes (self ):
339
334
otel_asgi .set_status_code (self .span , 404 )
0 commit comments