Skip to content

Commit

Permalink
Fix Issue Speedygeek#345 + Speedygeek#337 + Fix UserTests that failed…
Browse files Browse the repository at this point in the history
…/was incorrectly implemented (Speedygeek#349)

* Test "CanCreateTicketWithDueDate" can't run on PCs that use dd/MM/yyyy as time format

* Added Code to make tests work

* - Added support for issue Speedygeek#330
- Added support for CRUD operations of Comments on Articles and Posts

* Implementation of "Users.GetIncrementalUserExport" and "Users.GetIncrementalUserExportNextPage" (+Async versions)

* Changes to PR based on @mozts2005’s request

* Changed Assert Style

* Fixed Issue Speedygeek#345

+

Fixed test UserTests.CanCreateUpdateSuspendAndDeleteUser could fail as it assumed the user was among the 100 to be returned but it is not (at least not now).

* Added missing Obsolete Attribute

* Fix Issue Speedygeek#337 + Added missing tests
  • Loading branch information
rwjdk-test authored and mozts2005 committed Jul 3, 2018
1 parent 5822e69 commit daf5ee1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ public class SatisfactionRating

[JsonProperty("comment")]
public string Comment { get; set; }

[JsonProperty("reason")]
public string Reason { get; set; }
}
}
16 changes: 15 additions & 1 deletion src/ZendeskApi_v2/Requests/Tickets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ public interface ITickets : ICore

Task<bool> MarkAuditAsTrustedAsync(long ticketId, long auditId);

[Obsolete("This has been deprecated due to wrong spelling and sideLoadOptions was ignored. Please use GetIncrementalTicketExportAsync instead")]
Task<GroupTicketExportResponse> GetInrementalTicketExportAsync(DateTimeOffset startTime, TicketSideLoadOptionsEnum sideLoadOptions = TicketSideLoadOptionsEnum.None);

Task<GroupTicketExportResponse> GetIncrementalTicketExportAsync(DateTimeOffset startTime, TicketSideLoadOptionsEnum sideLoadOptions = TicketSideLoadOptionsEnum.None);


/// <summary>
/// Since the other method can only be called once every 5 minutes it is not sutable for Automated tests.
/// </summary>
Expand Down Expand Up @@ -810,11 +814,21 @@ public async Task<bool> MarkAuditAsTrustedAsync(long ticketId, long auditId)
return await res.ContinueWith(x => x.Result.HttpStatusCode == HttpStatusCode.OK);
}

[Obsolete("This has been deprecated due to wrong spelling and sideLoadOptions was ignored. Please use GetIncrementalTicketExportAsync instead")]
public async Task<GroupTicketExportResponse> GetInrementalTicketExportAsync(DateTimeOffset startTime, TicketSideLoadOptionsEnum sideLoadOptions = TicketSideLoadOptionsEnum.None)
{
return await GenericPagedGetAsync<GroupTicketExportResponse>(_incremental_export + startTime.UtcDateTime.GetEpoch());
}

public async Task<GroupTicketExportResponse> GetIncrementalTicketExportAsync(DateTimeOffset startTime, TicketSideLoadOptionsEnum sideLoadOptions = TicketSideLoadOptionsEnum.None)
{
var resource = GetResourceStringWithSideLoadOptionsParam(
_incremental_export + startTime.UtcDateTime.GetEpoch(),
sideLoadOptions
);
return await GenericPagedGetAsync<GroupTicketExportResponse>(resource);
}

/// <summary>
/// Since the other method can only be called once every 5 minutes it is not sutable for Automated tests.
/// </summary>
Expand Down Expand Up @@ -975,4 +989,4 @@ private string GetResourceStringWithSideLoadOptionsParam(string resource, Ticket
return resource;
}
}
}
}
16 changes: 14 additions & 2 deletions test/ZendeskApi_v2.Test/SatisfactionRatingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ public class SatisfactionRatingTests
private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword);

[Test]
public void CanGetSatisfactionRatings()
public void CanGetBadSatisfactionRatings()
{
//there is no way to create satisfaction ratings through the api so they can't be tested
var receivedSatisfactionRating = api.SatisfactionRatings.GetSatisfactionRatingById(360342335066); //From Ticket 15157
Assert.That(receivedSatisfactionRating.SatisfactionRating.Score, Is.EqualTo("bad"));
Assert.That(receivedSatisfactionRating.SatisfactionRating.Comment, Is.EqualTo("poor job!"));
Assert.That(receivedSatisfactionRating.SatisfactionRating.Reason, Is.EqualTo("The issue was not resolved"));
}

[Test]
public void CanGetGoodSatisfactionRatings()
{
var receivedSatisfactionRating = api.SatisfactionRatings.GetSatisfactionRatingById(360342335186); //From Ticket 15156
Assert.That(receivedSatisfactionRating.SatisfactionRating.Score, Is.EqualTo("good"));
Assert.That(receivedSatisfactionRating.SatisfactionRating.Comment, Is.EqualTo("nice job!"));
Assert.That(receivedSatisfactionRating.SatisfactionRating.Reason, Is.EqualTo("No reason provided"));
}
}
}
9 changes: 9 additions & 0 deletions test/ZendeskApi_v2.Test/TicketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,15 @@ public void CanGetIncrementalTicketExportWithGroupsSideLoadPaged()
Assert.IsTrue(res.Groups.Count > 0);
}

[Test]
public async Task CanGetIncrementalTicketExportAsyncWithSideLoadOptions()
{
var res = await api.Tickets.GetIncrementalTicketExportAsync(DateTime.Now.AddDays(-31), TicketSideLoadOptionsEnum.Users);

Assert.That(res.Count, Is.GreaterThan(0));
Assert.That(res.Users, Is.Not.Null);
}

[Test]
public void CanGetTicketFields()
{
Expand Down
10 changes: 4 additions & 6 deletions test/ZendeskApi_v2.Test/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ public void CanGetUsersInOrgPaginated()
[Test]
public void CanCreateUpdateSuspendAndDeleteUser()
{
var list = api.Users.GetAllUsers();
var users = list.Users.Where(x => x.Email == "test772@tester.com");

foreach (var u in users)
var groupUserResponse = api.Users.SearchByEmail("test772@tester.com");
foreach (var u in groupUserResponse.Users)
{
api.Users.DeleteUser(u.Id.Value);
}
Expand Down Expand Up @@ -550,13 +548,13 @@ public async Task CanGetIncrementalUserExportAsync()
public async Task CanGetIncrementalUserExportAsyncWithSideLoadOptions()
{
var incrementalUserExport = await api.Users.GetIncrementalUserExportAsync(DateTimeOffset.MinValue, UserSideLoadOptions.Organizations | UserSideLoadOptions.Groups | UserSideLoadOptions.Identities);
Assert.That(incrementalUserExport.Users.Count > 0);
Assert.That(incrementalUserExport.Users.Count, Is.GreaterThan(0));
Assert.That(incrementalUserExport.Organizations, Is.Not.Null);
Assert.That(incrementalUserExport.Identities, Is.Not.Null);
Assert.That(incrementalUserExport.Groups, Is.Not.Null);

var incrementalUserExportNextPage = await api.Users.GetIncrementalUserExportNextPageAsync(incrementalUserExport.NextPage);
Assert.That(incrementalUserExportNextPage.Users.Count > 0);
Assert.That(incrementalUserExportNextPage.Users.Count, Is.GreaterThan(0));
Assert.That(incrementalUserExportNextPage.Organizations, Is.Not.Null);
Assert.That(incrementalUserExportNextPage.Identities, Is.Not.Null);
Assert.That(incrementalUserExportNextPage.Groups, Is.Not.Null);
Expand Down

0 comments on commit daf5ee1

Please sign in to comment.