8
8
import pytest # noqa, F401
9
9
10
10
11
+ def clean_id (id ):
12
+ return id .replace ("-" , "" )
13
+
14
+
11
15
def test_block_content (notion_token ):
12
16
notion_api = NotionApi (token = notion_token )
13
17
test_page = get_test_page ()
14
18
15
19
block = test_page .children .add_new (TextBlock , title = "test get block content" )
16
20
content = notion_api .block_content (block .id )
17
21
18
- assert content == {"id" : block .id , "title" : "test get block content" }
22
+ assert content == {"id" : clean_id ( block .id ) , "title" : "test get block content" }
19
23
20
24
21
25
def test_block_children (notion_token ):
@@ -28,9 +32,9 @@ def test_block_children(notion_token):
28
32
29
33
content = notion_api .block_children (block .id )
30
34
31
- assert content ["parent" ] == {"id" : block .id , "title" : "a parent block" }
32
- assert content ["children" ][0 ] == {"id" : child_block_1 .id , "title" : "child block 1" }
33
- assert content ["children" ][1 ] == {"id" : child_block_2 .id , "title" : "child block 2" }
35
+ assert content ["parent" ] == {"id" : clean_id ( block .id ) , "title" : "a parent block" }
36
+ assert content ["children" ][0 ] == {"id" : clean_id ( child_block_1 .id ) , "title" : "child block 1" }
37
+ assert content ["children" ][1 ] == {"id" : clean_id ( child_block_2 .id ) , "title" : "child block 2" }
34
38
35
39
36
40
def test_block_append (notion_token ):
@@ -40,8 +44,8 @@ def test_block_append(notion_token):
40
44
block = test_page .children .add_new (TextBlock , title = "test block append" )
41
45
new_block = notion_api .block_append (block .id , {"title" : "appending text" })
42
46
43
- assert new_block == {"id" : new_block .block .id , "title" : "appending text" }
44
- assert new_block .block .parent .id == block .id
47
+ assert new_block == {"id" : clean_id ( new_block .block .id ) , "title" : "appending text" }
48
+ assert clean_id ( new_block .block .parent .id ) == clean_id ( block .id )
45
49
46
50
47
51
def test_block_update_with_text_block (notion_token ):
@@ -51,7 +55,7 @@ def test_block_update_with_text_block(notion_token):
51
55
block = test_page .children .add_new (TextBlock , title = "test block update" )
52
56
updated_block = notion_api .block_update (block .id , {"title" : "test block has been updated" })
53
57
54
- assert updated_block == {"id" : block .id , "title" : "test block has been updated" }
58
+ assert updated_block == {"id" : clean_id ( block .id ) , "title" : "test block has been updated" }
55
59
56
60
57
61
def test_block_update_with_collection_block (notion_token ):
@@ -62,7 +66,7 @@ def test_block_update_with_collection_block(notion_token):
62
66
63
67
updated_block = notion_api .block_update (block .id , {"name" : "test block has been updated" , "value" : 5 })
64
68
65
- assert updated_block == {"id" : block .id , "name" : "test block has been updated" , "value" : 5 , "category" : None , "enabled" : True , "tags" : []}
69
+ assert updated_block == {"id" : clean_id ( block .id ) , "name" : "test block has been updated" , "value" : 5 , "category" : None , "enabled" : True , "tags" : []}
66
70
67
71
68
72
def test_block_delete_with_text_block (notion_token ):
@@ -114,8 +118,8 @@ def test_collection_view_content(notion_token):
114
118
collection_view_content = notion_api .collection_view_content (collection_id .replace ("-" , "" ), view_id .replace ("-" , "" ))
115
119
116
120
assert collection_view_content ["collection" ] == {
117
- "collection_id" : collection_id ,
118
- "view_id" : view_id ,
121
+ "collection_id" : clean_id ( collection_id ) ,
122
+ "view_id" : clean_id ( view_id ) ,
119
123
"collection_title" : "Test collection" ,
120
124
"view_title" : "Test view"
121
125
}
0 commit comments