2
2
3
3
from .notion_api_page_helper import get_test_page , create_collection_view
4
4
5
- from notion .block import TextBlock
5
+ from notion .block import TextBlock , DividerBlock
6
6
7
7
import json
8
8
@@ -13,21 +13,43 @@ def clean_id(id):
13
13
return id .replace ("-" , "" )
14
14
15
15
16
- def test_block_presentation (notion_token ):
16
+ def test_text_block_presentation (notion_token ):
17
17
test_page = get_test_page ()
18
18
19
19
block = test_page .children .add_new (TextBlock , title = "textblock" )
20
+ assert BlockPresenter (block ).block == block
21
+ assert BlockPresenter (block ) == {"id" : clean_id (block .id ), "block_type" : "text" , "title" : "textblock" }
22
+ assert json .dumps (BlockPresenter (block )) == '{"id": "%s", "block_type": "text", "title": "textblock"}' % clean_id (block .id )
23
+
20
24
25
+ def test_divider_block_presentation (notion_token ):
26
+ test_page = get_test_page ()
27
+
28
+ block = test_page .children .add_new (DividerBlock )
21
29
assert BlockPresenter (block ).block == block
22
- assert BlockPresenter (block ) == {"id" : clean_id (block .id ), "title " : "textblock " }
23
- assert json .dumps (BlockPresenter (block )) == '{"id": "%s", "title ": "textblock "}' % clean_id (block .id )
30
+ assert BlockPresenter (block ) == {"id" : clean_id (block .id ), "block_type " : "divider " }
31
+ assert json .dumps (BlockPresenter (block )) == '{"id": "%s", "block_type ": "divider "}' % clean_id (block .id )
24
32
25
33
26
34
def test_collection_row_block_presentation (notion_token ):
27
35
collection_view = create_collection_view ()
28
36
block = collection_view .collection .add_row (name = "test row" , value = 10 , enabled = True )
29
37
30
38
assert BlockPresenter (block ).block == block
31
- assert BlockPresenter (block ) == {"id" : clean_id (block .id ), "enabled" : True , "tags" : [], "category" : None , "value" : 10 , "name" : "test row" }
39
+ assert BlockPresenter (block ) == {"id" : clean_id (block .id ), "block_type" : "page" , "enabled" : True ,
40
+ "tags" : [], "category" : None , "value" : 10 , "name" : "test row" }
41
+ assert json .dumps (BlockPresenter (
42
+ block )) == '{"id": "%s", "block_type": "page", "enabled": true, "tags": [], "category": null, "value": 10, "name": "test row"}' % clean_id (block .id )
43
+
44
+
45
+ def test_collection_view_presentation (notion_token ):
46
+ collection_view = create_collection_view ()
47
+ collection_view .name = "Test view"
48
+
49
+ assert BlockPresenter (collection_view ).block == collection_view
50
+ assert BlockPresenter (collection_view ) == {"collection_id" : clean_id (collection_view .parent .id ),
51
+ "collection_title" : "Test collection" , "view_id" : clean_id (collection_view .id ), "view_title" : "Test view" }
52
+
53
+ json_string_template = '{"collection_id": "%s", "view_id": "%s", "collection_title": "Test collection", "view_title": "Test view"}'
32
54
assert json .dumps (BlockPresenter (
33
- block )) == '{"id": "%s", "enabled": true, "tags": [], "category": null, "value": 10, "name": "test row"}' % clean_id (block .id )
55
+ collection_view )) == json_string_template % ( clean_id ( collection_view . parent . id ), clean_id (collection_view .id ) )
0 commit comments