@@ -77,21 +77,9 @@ def test_get_url():
7777
7878@pytest .mark .vcr ()
7979@pytest .mark .timeout (90 )
80- def test_iterate_paginated_api (client , parent_page_id ):
81- def create_page (page_name ):
82- page = client .pages .create (
83- parent = {"page_id" : parent_page_id },
84- properties = {"title" : [{"text" : {"content" : page_name }}]},
85- children = [],
86- )
87- return page ["id" ]
88-
89- page_ids = []
90- for i in range (0 , 5 ):
91- page_id = create_page (f"Test Page (test_iterate_paginated_api iteration { i } )" )
92- page_ids .append (page_id )
93-
94- # give time to Notion to index these pages
80+ def test_iterate_paginated_api (client , multiple_test_pages ):
81+ page_ids = multiple_test_pages
82+
9583 time .sleep (20 )
9684
9785 generator = iterate_paginated_api (
@@ -132,23 +120,9 @@ def test_collect_paginated_api(client):
132120
133121@pytest .mark .vcr ()
134122@pytest .mark .timeout (90 )
135- async def test_async_iterate_paginated_api (async_client , parent_page_id ):
136- async def create_page (page_name ):
137- page = await async_client .pages .create (
138- parent = {"page_id" : parent_page_id },
139- properties = {"title" : [{"text" : {"content" : page_name }}]},
140- children = [],
141- )
142- return page ["id" ]
143-
144- page_ids = []
145- for i in range (0 , 5 ):
146- page_id = await create_page (
147- f"Test Page (test_async_iterate_paginated_api iteration { i } )"
148- )
149- page_ids .append (page_id )
150-
151- # give time to Notion to index these pages
123+ async def test_async_iterate_paginated_api (async_client , async_multiple_test_pages ):
124+ page_ids = async_multiple_test_pages
125+
152126 await asyncio .sleep (20 )
153127
154128 generator = async_iterate_paginated_api (
@@ -549,19 +523,10 @@ def test_collect_data_source_templates(client, data_source_id):
549523
550524
551525@pytest .mark .vcr ()
552- async def test_async_iterate_data_source_templates (async_client , parent_page_id ):
553- database = await async_client .databases .create (
554- parent = {"type" : "page_id" , "page_id" : parent_page_id },
555- title = [{"type" : "text" , "text" : {"content" : "Async Test DB" }}],
556- )
557- database_id = database ["id" ]
558-
559- data_source_response = await async_client .data_sources .create (
560- parent = {"type" : "database_id" , "database_id" : database_id },
561- properties = {"Name" : {"type" : "title" , "title" : {}}},
562- title = [{"type" : "text" , "text" : {"content" : "Async Test Data Source" }}],
563- )
564- data_source_id = data_source_response ["id" ]
526+ async def test_async_iterate_data_source_templates (
527+ async_client , async_test_data_source
528+ ):
529+ data_source_id = async_test_data_source
565530
566531 generator = async_iterate_data_source_templates (
567532 async_client .data_sources .list_templates ,
@@ -571,31 +536,16 @@ async def test_async_iterate_data_source_templates(async_client, parent_page_id)
571536 templates = [template async for template in generator ]
572537 assert isinstance (templates , list )
573538
574- await async_client .data_sources .update (data_source_id , archived = True )
575- await async_client .blocks .delete (block_id = database_id )
576-
577539
578540@pytest .mark .vcr ()
579- async def test_async_collect_data_source_templates (async_client , parent_page_id ):
580- database = await async_client .databases .create (
581- parent = {"type" : "page_id" , "page_id" : parent_page_id },
582- title = [{"type" : "text" , "text" : {"content" : "Async Test DB 2" }}],
583- )
584- database_id = database ["id" ]
585-
586- data_source_response = await async_client .data_sources .create (
587- parent = {"type" : "database_id" , "database_id" : database_id },
588- properties = {"Name" : {"type" : "title" , "title" : {}}},
589- title = [{"type" : "text" , "text" : {"content" : "Async Test Data Source 2" }}],
590- )
591- data_source_id = data_source_response ["id" ]
541+ async def test_async_collect_data_source_templates (
542+ async_client , async_test_data_source
543+ ):
544+ data_source_id = async_test_data_source
592545
593546 templates = await async_collect_data_source_templates (
594547 async_client .data_sources .list_templates ,
595548 data_source_id = data_source_id ,
596549 )
597550
598551 assert isinstance (templates , list )
599-
600- await async_client .data_sources .update (data_source_id , archived = True )
601- await async_client .blocks .delete (block_id = database_id )
0 commit comments