Skip to content

Commit b1f21ac

Browse files
Add test cases to check database parent property ✅
1 parent 0fb7a03 commit b1f21ac

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,26 @@ public async Task DatabasePropertyObjectContainNameProperty()
6262
property.Key.Should().Be(property.Value.Name);
6363
}
6464
}
65+
66+
[Fact]
67+
public async Task DatabasePropertyObjectContainParentProperty()
68+
{
69+
var databaseId = "f0212efc-caf6-4afc-87f6-1c06f1dfc8a1";
70+
var path = ApiEndpoints.DatabasesApiUrls.Retrieve(databaseId);
71+
var jsonData = await File.ReadAllTextAsync("data/databases/DatabasePropertyObjectContainParentProperty.json");
72+
73+
Server.Given(CreateGetRequestBuilder(path))
74+
.RespondWith(
75+
Response.Create()
76+
.WithStatusCode(200)
77+
.WithBody(jsonData)
78+
);
79+
80+
var database = await _client.RetrieveAsync(databaseId);
81+
82+
database.Parent.Type.Should().Be(ParentType.PageId);
83+
database.Parent.Should().BeOfType<PageParent>();
84+
((PageParent)database.Parent).PageId.Should().Be("649089db-8984-4051-98fb-a03593b852d8");
85+
}
6586
}
6687
}

Test/Notion.UnitTests/Notion.UnitTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30+
<None Update="data\databases\DatabasePropertyObjectContainParentProperty.json">
31+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
32+
</None>
3033
<None Update="data\pages\CreatePageResponse.json">
3134
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3235
</None>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"object": "database",
3+
"id": "f0212efc-caf6-4afc-87f6-1c06f1dfc8a1",
4+
"created_time": "2021-05-22T18:44:00.000Z",
5+
"last_edited_time": "2021-05-23T12:29:00.000Z",
6+
"title": [
7+
{
8+
"type": "text",
9+
"text": {
10+
"content": "sample table",
11+
"link": null
12+
},
13+
"annotations": {
14+
"bold": false,
15+
"italic": false,
16+
"strikethrough": false,
17+
"underline": false,
18+
"code": false,
19+
"color": "default"
20+
},
21+
"plain_text": "sample table",
22+
"href": null
23+
}
24+
],
25+
"properties": {
26+
"Tags": {
27+
"id": "YG~h",
28+
"name": "Tags",
29+
"type": "multi_select",
30+
"multi_select": {
31+
"options": []
32+
}
33+
},
34+
"SimpleText": {
35+
"id": "_Dfp",
36+
"name": "SimpleText",
37+
"type": "rich_text",
38+
"rich_text": {}
39+
},
40+
"Column": {
41+
"id": "bxhl",
42+
"name": "Column",
43+
"type": "multi_select",
44+
"multi_select": {
45+
"options": [
46+
{
47+
"id": "5a44a233-33be-435e-b358-2c0ed1799dcf",
48+
"name": "what",
49+
"color": "gray"
50+
}
51+
]
52+
}
53+
},
54+
"SelectProp": {
55+
"id": "eZ[y",
56+
"name": "SelectProp",
57+
"type": "select",
58+
"select": {
59+
"options": [
60+
{
61+
"id": "362dc255-c867-4543-b3ea-7bd988638228",
62+
"name": "Female",
63+
"color": "green"
64+
}
65+
]
66+
}
67+
},
68+
"Property": {
69+
"id": "zDGa",
70+
"name": "Property",
71+
"type": "relation",
72+
"relation": {
73+
"database_id": "f86f2262-0751-40f2-8f63-e3f7a3c39fcb",
74+
"synced_property_name": "Related to sample table (Property)",
75+
"synced_property_id": "VQ}{"
76+
}
77+
},
78+
"Name": {
79+
"id": "title",
80+
"name": "Name",
81+
"type": "title",
82+
"title": {}
83+
}
84+
},
85+
"parent": {
86+
"type": "page_id",
87+
"page_id": "649089db-8984-4051-98fb-a03593b852d8"
88+
}
89+
}

0 commit comments

Comments
 (0)