8000 Fix broken test cases · notion-dotnet/notion-sdk-net@d9b152a · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit d9b152a

Browse files
Fix broken test cases
1 parent 75cbf61 commit d9b152a

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,14 @@ public async Task Fix123_QueryAsync_DateFormulaValue_Returns_Null()
464464
page.Parent.Should().BeAssignableTo<IPageParent>();
465465
page.Object.Should().Be(ObjectType.Page);
466466

467-
var formulaPropertyValue = (FormulaPropertyValue)await _pagesClient.RetrievePagePropertyItem(new RetrievePropertyItemParameters
467+
Server.Given(CreateGetRequestBuilder(ApiEndpoints.PagesApiUrls.RetrievePropertyItem(page.Id, page.Properties["FormulaProp"].Id)))
468+
.RespondWith(
469+
Response.Create()
470+
.WithStatusCode(200)
471+
.WithBody("{\"object\":\"property_item\",\"id\":\"JwY^\",\"type\":\"formula\",\"formula\":{\"type\":\"date\",\"date\":{\"start\":\"2021-06-28\",\"end\":null}}}")
472+
);
473+
474+
var formulaPropertyValue = (FormulaPropertyItem)await _pagesClient.RetrievePagePropertyItem(new RetrievePropertyItemParameters
468475
{
469476
PageId = page.Id,
470477
PropertyId = page.Properties["FormulaProp"].Id

Test/Notion.UnitTests/PagesClientTests.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public async Task CreateAsync()
8888
public async Task UpdatePropertiesAsync()
8989
{
9090
var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c";
91+
var propertyId = "{>U;";
9192
var path = ApiEndpoints.PagesApiUrls.UpdateProperties(pageId);
9293

9394
var jsonData = await File.ReadAllTextAsync("data/pages/UpdatePagePropertiesResponse.json");
@@ -99,6 +100,10 @@ public async Task UpdatePropertiesAsync()
99100
.WithBody(jsonData)
100101
);
101102

103+
Server.Given(CreateGetRequestBuilder(ApiEndpoints.PagesApiUrls.RetrievePropertyItem(pageId, propertyId)))
104+
.RespondWith(
105+
Response.Create().WithStatusCode(200).WithBody("{\"object\":\"property_item\",\"id\":\"{>U;\",\"type\":\"checkbox\",\"checkbox\":true}"));
106+
102107
var updatedProperties = new Dictionary<string, PropertyValue>()
103108
{
104109
{ "In stock", new CheckboxPropertyValue() { Checkbox = true } }
@@ -110,7 +115,7 @@ public async Task UpdatePropertiesAsync()
110115
page.Properties.Should().HaveCount(2);
111116
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
112117

113-
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
118+
var checkboxPropertyValue = (CheckboxPropertyItem)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
114119
{
115120
PageId = page.Id,
116121
PropertyId = updatedProperty.Value.Id
@@ -142,6 +147,7 @@ public async Task PageObjectShouldHaveUrlProperty()
142147
public async Task UpdatePageAsync()
143148
{
144149
var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c";
150+
var propertyId = "{>U;";
145151
var path = ApiEndpoints.PagesApiUrls.UpdateProperties(pageId);
146152

147153
var jsonData = await File.ReadAllTextAsync("data/pages/UpdatePagePropertiesResponse.json");
@@ -153,6 +159,10 @@ public async Task UpdatePageAsync()
153159
.WithBody(jsonData)
154160
);
155161

162+
Server.Given(CreateGetRequestBuilder(ApiEndpoints.PagesApiUrls.RetrievePropertyItem(pageId, propertyId)))
163+
.RespondWith(
164+
Response.Create().WithStatusCode(200).WithBody("{\"object\":\"property_item\",\"id\":\"{>U;\",\"type\":\"checkbox\",\"checkbox\":true}"));
165+
156166
var pagesUpdateParameters = new PagesUpdateParameters
157167
{
158168
Properties = new Dictionary<string, PropertyValue>()
@@ -168,7 +178,7 @@ public async Task UpdatePageAsync()
168178
page.Properties.Should().HaveCount(2);
169179
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
170180

171-
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
181+
var checkboxPropertyValue = (CheckboxPropertyItem)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
172182
{
173183
PageId = page.Id,
174184
PropertyId = updatedProperty.Value.Id
@@ -181,6 +191,8 @@ public async Task UpdatePageAsync()
181191
public async Task ArchivePageAsync()
182192
{
183193
var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c";
194+
var propertyId = "{>U;";
195+
184196
var path = ApiEndpoints.PagesApiUrls.UpdateProperties(pageId);
185197

186198
var jsonData = await File.ReadAllTextAsync("data/pages/ArchivePageResponse.json");
@@ -192,6 +204,10 @@ public async Task ArchivePageAsync()
192204
.WithBody(jsonData)
193205
);
194206

207+
Server.Given(CreateGetRequestBuilder(ApiEndpoints.PagesApiUrls.RetrievePropertyItem(pageId, propertyId)))
208+
.RespondWith(
209+
Response.Create().WithStatusCode(200).WithBody("{\"object\":\"property_item\",\"id\":\"{>U;\",\"type\":\"checkbox\",\"checkbox\":true}"));
210+
195211
var pagesUpdateParameters = new PagesUpdateParameters
196212
{
197213
Archived = true,
@@ -208,7 +224,7 @@ public async Task ArchivePageAsync()
208224
page.Properties.Should().HaveCount(2);
209225
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
210226

211-
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
227+
var checkboxPropertyValue = (CheckboxPropertyItem)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
212228
{
213229
PageId = page.Id,
214230
PropertyId = updatedProperty.Value.Id

Test/Notion.UnitTests/data/databases/Fix123QueryAsyncDateFormulaValueReturnsNullResponse.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
},
3838
"FormulaProp": {
39-
"id": "JwY^",
39+
"id": "JwY",
4040
"type": "formula",
4141
"formula": {
4242
"type": "date",

0 commit comments

Comments
 (0)
0