@@ -295,7 +295,7 @@ def setUp(self):
295295 setup_testing_defaults (self .scope )
296296 self .span = mock .create_autospec (trace_api .Span , spec_set = True )
297297
298- def test_query_string_utf8 (self ):
298+ def test_request_attributes (self ):
299299 self .scope ["query_string" ] = b"foo=bar"
300300
301301 attrs = otel_asgi .collect_request_attributes (self .scope )
@@ -315,25 +315,20 @@ def test_query_string_utf8(self):
315315 },
316316 )
317317
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" )
320322
323+ def test_query_string_percent_bytes (self ):
324+ self .scope ["query_string" ] = b"foo%3Dbar"
321325 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" )
337332
338333 def test_response_attributes (self ):
339334 otel_asgi .set_status_code (self .span , 404 )
0 commit comments