@@ -96,12 +96,38 @@ async def test_write_multi_message_with_ack(
9696 None ,
9797 ],
9898 )
99- async def test_write_encoded (self , driver : ydb .Driver , topic_path : str , codec ):
99+ async def test_write_encoded (self , driver : ydb .aio . Driver , topic_path : str , codec ):
100100 async with driver .topic_client .writer (topic_path , codec = codec ) as writer :
101101 await writer .write ("a" * 1000 )
102102 await writer .write ("b" * 1000 )
103103 await writer .write ("c" * 1000 )
104104
105+ async def test_create_writer_after_stop (self , driver : ydb .aio .Driver , topic_path : str ):
106+ await driver .stop ()
107+ with pytest .raises (ydb .Error ):
108+ async with driver .topic_client .writer (topic_path ) as writer :
109+ await writer .write_with_ack ("123" )
110+
111+ async def test_send_message_after_stop (self , driver : ydb .aio .Driver , topic_path : str ):
112+ writer = driver .topic_client .writer (topic_path )
113+ await driver .stop ()
114+ with pytest .raises (ydb .Error ):
115+ await writer .write_with_ack ("123" )
116+
117+ async def test_preserve_exception_on_cm_close (self , driver : ydb .aio .Driver , topic_path : str ):
118+ class TestException (Exception ):
119+ pass
120+
121+ with pytest .raises (TestException ):
122+ async with driver .topic_client .writer (topic_path ) as writer :
123+ driver .stop () # will raise exception on topic writer __exit__
124+ try :
125+ writer .write ("123" )
126+ except ydb .Error :
127+ pass
128+
129+ raise TestException ()
130+
105131
106132class TestTopicWriterSync :
107133 def test_send_message (self , driver_sync : ydb .Driver , topic_path ):
@@ -212,3 +238,29 @@ def test_start_many_sync_writers_in_parallel(self, driver_sync: ydb.Driver, topi
212238
213239 for writer in writers :
214240 writer .close ()
241+
242+ def test_create_writer_after_stop (self , driver_sync : ydb .Driver , topic_path : str ):
243+ driver_sync .stop ()
244+ with pytest .raises (ydb .Error ):
245+ with driver_sync .topic_client .writer (topic_path ) as writer :
246+ writer .write_with_ack ("123" )
247+
248+ def test_send_message_after_stop (self , driver_sync : ydb .Driver , topic_path : str ):
249+ writer = driver_sync .topic_client .writer (topic_path )
250+ driver_sync .stop ()
251+ with pytest .raises (ydb .Error ):
252+ writer .write_with_ack ("123" )
253+
254+ def test_preserve_exception_on_cm_close (self , driver_sync : ydb .Driver , topic_path : str ):
255+ class TestException (Exception ):
256+ pass
257+
258+ with pytest .raises (TestException ):
259+ with driver_sync .topic_client .writer (topic_path ) as writer :
260+ driver_sync .stop () # will raise exception on topic writer __exit__
261+ try :
262+ writer .write ("123" )
263+ except ydb .Error :
264+ pass
265+
266+ raise TestException ()
0 commit comments