Skip to content

Commit 34ecf9d

Browse files
committed
Add UpdateDatabaseRelationProperties Test
1 parent b842ed7 commit 34ecf9d

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

Test/Notion.IntegrationTests/DatabasesClientTests.cs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public async Task DisposeAsync()
2929
public async Task QueryDatabase()
3030
{
3131
// Arrange
32-
var createdDatabase = await CreateDatabaseWithAPageAsync();
32+
var createdDatabase = await CreateDatabaseWithAPageAsync("Test List");
3333

3434
// Act
3535
var response = await Client.Databases.QueryAsync(createdDatabase.Id, new DatabasesQueryParameters());
@@ -43,7 +43,64 @@ public async Task QueryDatabase()
4343
.Text.Content.Should().Be("Test Title");
4444
}
4545

46-
private async Task<Database> CreateDatabaseWithAPageAsync()
46+
[Fact]
47+
public async Task UpdateDatabaseRelationProperties()
48+
{
49+
// Arrange
50+
var createdSourceDatabase = await CreateDatabaseWithAPageAsync("Test Relation Source");
51+
var createdDestinationDatabase = await CreateDatabaseWithAPageAsync("Test Relation Destination");
52+
53+
// Act
54+
var response = await Client.Databases.UpdateAsync(createdDestinationDatabase.Id,
55+
new DatabasesUpdateParameters
56+
{
57+
Properties = new Dictionary<string, IUpdatePropertySchema>
58+
{
59+
{
60+
"Single Relation",
61+
new RelationUpdatePropertySchema
62+
{
63+
Relation = new SinglePropertyRelation
64+
{
65+
DatabaseId = createdSourceDatabase.Id,
66+
SingleProperty = new Dictionary<string, object>()
67+
}
68+
}
69+
},
70+
{
71+
"Dual Relation",
72+
new RelationUpdatePropertySchema
73+
{
74+
Relation = new DualPropertyRelation
75+
{
76+
DatabaseId = createdSourceDatabase.Id,
77+
DualProperty = new DualPropertyRelation.Data()
78+
}
79+
}
80+
}
81+
}
82+
});
83+
84+
// Assert
85+
response.Properties.Should().NotBeNull();
86+
87+
response.Properties.Should().ContainKey("Single Relation");
88+
var singleRelation = response.Properties["Single Relation"].As<RelationProperty>().Relation;
89+
singleRelation.Should().BeEquivalentTo(
90+
new SinglePropertyRelation
91+
{
92+
DatabaseId = createdSourceDatabase.Id,
93+
SingleProperty = new Dictionary<string, object>()
94+
});
95+
96+
response.Properties.Should().ContainKey("Dual Relation");
97+
var dualRelation = response.Properties["Dual Relation"].As<RelationProperty>().Relation;
98+
dualRelation.DatabaseId.Should().Be(createdSourceDatabase.Id);
99+
dualRelation.Type.Should().Be(RelationType.Dual);
100+
dualRelation.Should().BeOfType<DualPropertyRelation>();
101+
}
102+
103+
private async Task<Database> CreateDatabaseWithAPageAsync(string databaseName)
47104
{
48105
var createDbRequest = new DatabasesCreateParameters
49106
{
@@ -53,7 +110,7 @@ private async Task<Database> CreateDatabaseWithAPageAsync()
53110
{
54111
Text = new Text
55112
{
56-
Content = "Test List",
113+
Content = databaseName,
57114
Link = null
58115
}
59116
}

0 commit comments

Comments
 (0)