Skip to content

Commit

Permalink
Migrate to v9 API (#17)
Browse files Browse the repository at this point in the history
* Migrate to sync API v9
  • Loading branch information
olsh authored Oct 10, 2022
1 parent 7e3d3b8 commit 865f6f5
Show file tree
Hide file tree
Showing 53 changed files with 233 additions and 416 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov](https://codecov.io/gh/olsh/todoist-net/branch/master/graph/badge.svg)](https://codecov.io/gh/olsh/todoist-net)
[![NuGet](https://img.shields.io/nuget/v/Todoist.Net.svg)](https://www.nuget.org/packages/Todoist.Net/)

A [Todoist Sync API](https://developer.todoist.com/sync/v8/) client for .NET.
A [Todoist Sync API](https://developer.todoist.com/sync/v9/) client for .NET.
## Installation

The library is available as a [Nuget package](https://www.nuget.org/packages/Todoist.Net/).
Expand Down
29 changes: 10 additions & 19 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#tool nuget:?package=Codecov&version=1.13.0
#addin nuget:?package=Cake.Codecov&version=1.0.1

#tool nuget:?package=MSBuild.SonarQube.Runner.Tool&version=4.8.0
#addin nuget:?package=Cake.Sonar&version=1.1.30

Expand Down Expand Up @@ -36,36 +33,30 @@ Task("Build")
DotNetBuild(string.Format("{0}.sln", projectName), settings);
});

Task("Test")
Task("UnitTest")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetTestSettings
{
Configuration = buildConfiguration,
Loggers = new List<string> { "console;verbosity=detailed" }
Filter = "trait=unit"
};

DotNetTest(testProjectFile, settings);
});

Task("CodeCoverage")
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetTestSettings
{
Configuration = buildConfiguration,
Loggers = new List<string> { "console;verbosity=detailed" },
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:CoverletOutputFormat=opencover")
.Append("/p:Include=\"[Todoist.Net]*\"")
};

DotNetTest(testProjectFile, settings);
var settings = new DotNetTestSettings
{
Configuration = buildConfiguration,
Loggers = new List<string> { "console;verbosity=detailed" }
};

Codecov(string.Format("{0}coverage.net6.0.opencover.xml", testProjectFolder), EnvironmentVariable("codecov:token"));
DotNetTest(testProjectFile, settings);
});

Task("NugetPack")
Expand Down Expand Up @@ -121,7 +112,7 @@ Task("Default")
Task("CI")
.IsDependentOn("UpdateBuildVersion")
.IsDependentOn("Sonar")
.IsDependentOn("CodeCoverage")
.IsDependentOn("UnitTest")
.IsDependentOn("CreateArtifact");

RunTarget(target);
8 changes: 8 additions & 0 deletions src/Todoist.Net.Tests/Extensions/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ namespace Todoist.Net.Tests.Extensions;
internal static class Constants
{
public const string TodoistApiTestCollectionName = "todoist-api-tests";

public const string TraitName = "trait";

public const string UnitTraitValue = "unit";

public const string IntegrationFreeTraitValue = "integration-free";

public const string IntegrationPremiumTraitValue = "integration-premium";
}
9 changes: 0 additions & 9 deletions src/Todoist.Net.Tests/Extensions/CustomTraitBaseAttribute.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Todoist.Net.Tests/Extensions/IntegrationFreeAttribute.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Todoist.Net.Tests/Extensions/IntegrationPremiumAttribute.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Todoist.Net.Tests/Extensions/UnitAttribute.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Todoist.Net.Tests/Models/DueDateTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;

using Todoist.Net.Models;
using Todoist.Net.Tests.Extensions;
using Xunit;

namespace Todoist.Net.Tests.Models
{
[Unit]
[Trait(Constants.TraitName, Constants.UnitTraitValue)]
public class DueDateTests
{
[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Todoist.Net.Tests/Models/StringEnumTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Todoist.Net.Models;
using Todoist.Net.Models;
using Todoist.Net.Tests.Extensions;

using Xunit;

namespace Todoist.Net.Tests.Models
{
[Unit]
[Trait(Constants.TraitName, Constants.UnitTraitValue)]
public class StringEnumTests
{
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/ActivityServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public class ActivityServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/BackupServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public class BackupServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand All @@ -17,7 +18,6 @@ public BackupServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationFree]
public void GetBackups_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/EmailServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public EmailServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public void GetOrCreateAsyncDisable_NewProject_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/FiltersServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public class FiltersServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down
17 changes: 8 additions & 9 deletions src/Todoist.Net.Tests/Services/ItemsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ItemsServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public void CreateItemCompleteGetCloseAsync_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -45,7 +45,7 @@ public void CreateItemCompleteGetCloseAsync_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateItemCompleteUncompleteAsync_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -62,7 +62,6 @@ public void CreateItemCompleteUncompleteAsync_Success()

Assert.True(itemInfo.Item.IsChecked == true);

client.Items.UnArchiveAsync(itemId).Wait();
client.Items.UncompleteAsync(itemId).Wait();

var anotherItem = client.Items.GetAsync().Result.First(i => i.Id != item.Id);
Expand All @@ -84,7 +83,7 @@ public void CreateItemCompleteUncompleteAsync_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateItemClearDueDateAndDelete_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -108,7 +107,7 @@ public void CreateItemClearDueDateAndDelete_Success()


[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateItem_InvalidPDueDate_ThrowsException()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -125,7 +124,7 @@ public void CreateItem_InvalidPDueDate_ThrowsException()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void MoveItemsToProject_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down Expand Up @@ -153,7 +152,7 @@ public void MoveItemsToProject_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void QuickAddAsync_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -169,7 +168,7 @@ public void QuickAddAsync_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void UpdateOrders_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -184,7 +183,7 @@ public void UpdateOrders_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateNewItem_DueDateIsLocal_DueDateNotChanged()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/LabelsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public LabelsServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateUpdateOrderGetInfoDelete_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
6 changes: 3 additions & 3 deletions src/Todoist.Net.Tests/Services/NotesServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public NotesServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void AddNoteGetByIdAndDelete_Success()
{
var todoistClient = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -39,7 +39,7 @@ public void AddNoteGetByIdAndDelete_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void AddNoteToNewProjectAndUpdateIt_Success()
{
var todoistClient = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -57,7 +57,7 @@ public void AddNoteToNewProjectAndUpdateIt_Success()
}

[Fact]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public void AddNoteToNewProjectAttachFileAndDeleteIt_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public class NotificationsServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down
12 changes: 6 additions & 6 deletions src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ProjectsServiceTests(ITestOutputHelper outputHelper)
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateGetAndDelete_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -42,7 +42,7 @@ public void CreateGetAndDelete_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateUpdateOrderMoveAndDelete_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -51,20 +51,20 @@ public void CreateUpdateOrderMoveAndDelete_Success()
var project = new Project(projectName);
client.Projects.AddAsync(project).Wait();

Assert.True(project.Id != default(int));
Assert.True(project.Id != default(string));

project.Name = "u_" + Guid.NewGuid();

client.Projects.UpdateAsync(project).Wait();

client.Projects.ReorderAsync(new ReorderEntry(project.Id, 1)).Wait();
client.Projects.MoveAsync(new MoveArgument(project.Id, null));
client.Projects.MoveAsync(new MoveArgument(project.Id, null)).Wait();

client.Projects.DeleteAsync(project.Id).Wait();
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateArchiveAndDelete_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand All @@ -86,7 +86,7 @@ public void CreateArchiveAndDelete_Success()
}

[Fact]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public void CreateProjectAndGetProjectData_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/ReminersServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[IntegrationPremium]
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
public class ReminersServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net.Tests/Services/SectionServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Todoist.Net.Tests.Services
{
[Collection(Constants.TodoistApiTestCollectionName)]
[IntegrationFree]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
public class SectionServiceTests
{
private readonly ITestOutputHelper _outputHelper;
Expand Down
Loading

0 comments on commit 865f6f5

Please sign in to comment.