@@ -15,39 +15,38 @@ async def test_params_empty(send_blocking_command):
1515
1616@pytest .mark .asyncio
1717@pytest .mark .parametrize ("value" , [None , True , "foo" , 42 , {}])
18- async def test_params_events_invalid_type (send_blocking_command , value ):
18+ async def test_params_events_invalid_type (bidi_session , value ):
1919 with pytest .raises (InvalidArgumentException ):
20- await send_blocking_command ( " session.subscribe" , { " events" : value } )
20+ await bidi_session . session .subscribe ( events = value )
2121
2222
2323@pytest .mark .asyncio
2424async def test_params_events_empty (bidi_session ):
25- response = await bidi_session . session . subscribe ( events = [])
26- assert response == {}
25+ with pytest . raises ( InvalidArgumentException ):
26+ await bidi_session . session . subscribe ( events = [])
2727
2828
2929@pytest .mark .asyncio
3030@pytest .mark .parametrize ("value" , [None , True , 42 , [], {}])
31- async def test_params_events_value_invalid_type (send_blocking_command , value ):
31+ async def test_params_events_value_invalid_type (bidi_session , value ):
3232 with pytest .raises (InvalidArgumentException ):
33- await send_blocking_command ( " session.subscribe" , { " events" : [value ]} )
33+ await bidi_session . session .subscribe ( events = [value ])
3434
3535
3636@pytest .mark .asyncio
3737@pytest .mark .parametrize ("value" , ["" , "foo" , "foo.bar" , "log.invalidEvent" ])
38- async def test_params_events_value_invalid_event_name (send_blocking_command , value ):
38+ async def test_params_events_value_invalid_event_name (bidi_session , value ):
3939 with pytest .raises (InvalidArgumentException ):
40- await send_blocking_command ( " session.subscribe" , { " events" : [value ]} )
40+ await bidi_session . session .subscribe ( events = [value ])
4141
4242
4343@pytest .mark .asyncio
4444async def test_params_events_value_valid_and_invalid_event_names (
45- bidi_session , send_blocking_command , top_context
45+ bidi_session , top_context
4646):
4747 with pytest .raises (InvalidArgumentException ):
48- await send_blocking_command (
49- "session.subscribe" , {"events" : ["log.entryAdded" , "some.invalidEvent" ]}
50- )
48+ await bidi_session .session .subscribe (events = [
49+ "log.entryAdded" , "some.invalidEvent" ])
5150
5251 # Make sure that we didn't subscribe to log.entryAdded because of the error
5352
@@ -57,7 +56,8 @@ async def test_params_events_value_valid_and_invalid_event_names(
5756 async def on_event (method , data ):
5857 events .append (data )
5958
60- remove_listener = bidi_session .add_event_listener ("log.entryAdded" , on_event )
59+ remove_listener = bidi_session .add_event_listener (
60+ "log.entryAdded" , on_event )
6161
6262 await create_console_api_message (bidi_session , top_context , "text1" )
6363
@@ -70,57 +70,37 @@ async def on_event(method, data):
7070
7171@pytest .mark .asyncio
7272@pytest .mark .parametrize ("value" , [True , "foo" , 42 , {}])
73- async def test_params_contexts_invalid_type (send_blocking_command , value ):
73+ async def test_params_contexts_invalid_type (bidi_session , value ):
7474 with pytest .raises (InvalidArgumentException ):
75- await send_blocking_command (
76- "session.subscribe" ,
77- {
78- "events" : [],
79- "contexts" : value ,
80- }
81- )
75+ await bidi_session .session .subscribe (events = ["log.entryAdded" ], contexts = value )
8276
8377
8478@pytest .mark .asyncio
8579async def test_params_contexts_empty (bidi_session ):
86- response = await bidi_session . session . subscribe ( events = [], contexts = [])
87- assert response == {}
80+ with pytest . raises ( InvalidArgumentException ):
81+ await bidi_session . session . subscribe ( events = [ "log.entryAdded" ], contexts = [])
8882
8983
9084@pytest .mark .asyncio
9185@pytest .mark .parametrize ("value" , [None , True , 42 , [], {}])
92- async def test_params_contexts_value_invalid_type (send_blocking_command , value ):
86+ async def test_params_contexts_value_invalid_type (bidi_session , value ):
9387 with pytest .raises (InvalidArgumentException ):
94- await send_blocking_command (
95- "session.subscribe" ,
96- {
97- "events" : [],
98- "contexts" : [value ],
99- }
100- )
88+ await bidi_session .session .subscribe (events = ["log.entryAdded" ], contexts = [value ])
10189
10290
10391@pytest .mark .asyncio
104- async def test_params_contexts_value_invalid_value (send_blocking_command ):
92+ async def test_params_contexts_value_invalid_value (bidi_session ):
10593 with pytest .raises (NoSuchFrameException ):
106- await send_blocking_command (
107- "session.subscribe" ,
108- {
109- "events" : [],
110- "contexts" : ["foo" ],
111- }
112- )
94+ await bidi_session .session .subscribe (events = ["log.entryAdded" ], contexts = ["foo" ])
11395
11496
11597@pytest .mark .asyncio
11698async def test_params_contexts_valid_and_invalid_value (
117- bidi_session , send_blocking_command , top_context
99+ bidi_session , top_context
118100):
119101 with pytest .raises (NoSuchFrameException ):
120- await send_blocking_command (
121- "session.subscribe" ,
122- {"events" : ["log.entryAdded" ], "contexts" : [top_context ["context" ], "foo" ]},
123- )
102+ await bidi_session .session .subscribe (events = ["log.entryAdded" ], contexts = [
103+ top_context ["context" ], "foo" ])
124104
125105 # Make sure that we didn't subscribe to log.entryAdded because of error
126106
@@ -130,7 +110,8 @@ async def test_params_contexts_valid_and_invalid_value(
130110 async def on_event (method , data ):
131111 events .append (data )
132112
133- remove_listener = bidi_session .add_event_listener ("log.entryAdded" , on_event )
113+ remove_listener = bidi_session .add_event_listener (
114+ "log.entryAdded" , on_event )
134115
135116 await create_console_api_message (bidi_session , top_context , "text1" )
136117
@@ -142,16 +123,10 @@ async def on_event(method, data):
142123
143124
144125@pytest .mark .asyncio
145- async def test_subscribe_to_closed_tab (bidi_session , send_blocking_command ):
126+ async def test_subscribe_to_closed_tab (bidi_session ):
146127 new_tab = await bidi_session .browsing_context .create (type_hint = "tab" )
147128 await bidi_session .browsing_context .close (context = new_tab ["context" ])
148129
149130 # Try to subscribe to the closed context
150131 with pytest .raises (NoSuchFrameException ):
151- await send_blocking_command (
152- "session.subscribe" ,
153- {
154- "events" : ["log.entryAdded" ],
155- "contexts" : [new_tab ["context" ]]
156- },
157- )
132+ await bidi_session .session .subscribe (events = ["log.entryAdded" ], contexts = [new_tab ["context" ]])
0 commit comments