@@ -13,37 +13,73 @@ async def test_add_and_remove_cell(api_client: APIClient, notebook_maker):
1313 # TODO: remove sleep when Gate stops permission denied on newly created files (db time-travel)
1414 await asyncio .sleep (2 )
1515 rtu_client : RTUClient = await api_client .connect_realtime (file )
16- assert rtu_client .builder .nb .cells == []
16+ try :
17+ assert rtu_client .builder .nb .cells == []
1718
18- cell = await rtu_client .add_cell (source = 'print("hello world")' )
19- assert cell .cell_type == 'code'
20- assert cell .id in rtu_client .cell_ids
19+ cell = await rtu_client .add_cell (source = 'print("hello world")' )
20+ assert cell .cell_type == 'code'
21+ assert cell .id in rtu_client .cell_ids
2122
22- await rtu_client .delete_cell (cell .id )
23- with pytest .raises (CellNotFound ):
24- rtu_client .builder .get_cell (cell .id )
25-
26- await rtu_client .shutdown ()
23+ await rtu_client .delete_cell (cell .id )
24+ with pytest .raises (CellNotFound ):
25+ rtu_client .builder .get_cell (cell .id )
26+ finally :
27+ await rtu_client .shutdown ()
2728
2829
2930async def test_change_cell_type (api_client : APIClient , notebook_maker ):
3031 file : File = await notebook_maker ()
3132 # TODO: remove sleep when Gate stops permission denied on newly created files (db time-travel)
3233 await asyncio .sleep (2 )
3334 rtu_client : RTUClient = await api_client .connect_realtime (file )
34- assert rtu_client .builder .nb .cells == []
35+ try :
36+ assert rtu_client .builder .nb .cells == []
37+
38+ source_cell = await rtu_client .add_cell (source = '1 + 1' )
39+ _ , cell = rtu_client .builder .get_cell (source_cell .id )
40+ assert cell .cell_type == 'code'
41+
42+ await rtu_client .change_cell_type (cell .id , 'markdown' )
43+ _ , cell = rtu_client .builder .get_cell (source_cell .id )
44+ assert cell .cell_type == 'markdown'
45+
46+ await rtu_client .change_cell_type (cell .id , 'sql' )
47+ _ , cell = rtu_client .builder .get_cell (source_cell .id )
48+ assert cell .cell_type == 'code'
49+ assert cell .is_sql_cell
50+ finally :
51+ await rtu_client .shutdown ()
52+
53+
54+ async def test_update_cell_content (api_client : APIClient , notebook_maker ):
55+ file : File = await notebook_maker ()
56+ # TODO: remove sleep when Gate stops permission denied on newly created files (db time-travel)
57+ await asyncio .sleep (2 )
58+ rtu_client : RTUClient = await api_client .connect_realtime (file )
59+ try :
60+ assert rtu_client .builder .nb .cells == []
61+
62+ source_cell = await rtu_client .add_cell (source = '1 + 1' )
63+ _ , cell = rtu_client .builder .get_cell (source_cell .id )
64+
65+ cell = await rtu_client .update_cell_content (cell .id , '@@ -1,5 +1,5 @@\n -1 + 1\n +2 + 2\n ' )
66+ assert cell .source == '2 + 2'
67+ finally :
68+ await rtu_client .shutdown ()
3569
36- source_cell = await rtu_client .add_cell (source = '1 + 1' )
37- _ , cell = rtu_client .builder .get_cell (source_cell .id )
38- assert cell .cell_type == 'code'
3970
40- await rtu_client .change_cell_type (cell .id , 'markdown' )
41- _ , cell = rtu_client .builder .get_cell (source_cell .id )
42- assert cell .cell_type == 'markdown'
71+ async def test_replace_cell_content (api_client : APIClient , notebook_maker ):
72+ file : File = await notebook_maker ()
73+ # TODO: remove sleep when Gate stops permission denied on newly created files (db time-travel)
74+ await asyncio .sleep (2 )
75+ rtu_client : RTUClient = await api_client .connect_realtime (file )
76+ try :
77+ assert rtu_client .builder .nb .cells == []
4378
44- await rtu_client .change_cell_type (cell .id , 'sql' )
45- _ , cell = rtu_client .builder .get_cell (source_cell .id )
46- assert cell .cell_type == 'code'
47- assert cell .is_sql_cell
79+ source_cell = await rtu_client .add_cell (source = '1 + 1' )
80+ _ , cell = rtu_client .builder .get_cell (source_cell .id )
4881
49- await rtu_client .shutdown ()
82+ cell = await rtu_client .replace_cell_content (cell .id , '2 + 2' )
83+ assert cell .source == '2 + 2'
84+ finally :
85+ await rtu_client .shutdown ()
0 commit comments