Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV-11454] update tests #144

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ public async Task WaitAllFilesDownloadedOrFailedAsync_ShouldWaitUntilFilesDownlo
public async Task WaitFilesProcessedOrFailedAsync_ShouldWaitUntilAllFilesProcessedOrFailed()
{
// Arrange
var datasSet = await _dataHelper.DataSets().GetAny();
var dataSet = await _dataHelper.DataSets().GetAny();
var filePaths = new[] {_dataHelper.Files().GetSampleFilePath()};
await _dataSetsClient.AddFilesAsync(datasSet.Id, filePaths, default);
await _dataSetAwaiter.WaitFilesDownloadedOrFailedAsync(datasSet.Id, TimeSpan.Zero, default);
await _dataSetsClient.AddFilesAsync(dataSet.Id, filePaths, default);
await _dataSetAwaiter.WaitFilesDownloadedOrFailedAsync(dataSet.Id, TimeSpan.Zero, default);

var dataSetFileStatus = await _dataSetsClient.FileUploadStatusAsync(datasSet.Id, default);
var dataSetFileStatus = await _dataSetsClient.FileUploadStatusAsync(dataSet.Id, default);
var downloadedFileIds = dataSetFileStatus.Dataset.Files.Where(f => f.Status == FileStatus.Downloaded).Select(f => f.Id.Value);

await _dataSetsClient.ProcessFileAsync(datasSet.Id, downloadedFileIds, default);
await _dataSetsClient.ProcessFileAsync(dataSet.Id, downloadedFileIds, default);

// Act
await _dataSetAwaiter.WaitFilesProcessedOrFailedAsync(datasSet.Id, TimeSpan.Zero, default);
await _dataSetAwaiter.WaitFilesProcessedOrFailedAsync(dataSet.Id, TimeSpan.Zero, default);

// Assert
var dataSetWithStauses = await _dataSetsClient.FileUploadStatusAsync(datasSet.Id, default);
dataSetWithStauses.Dataset.Files
var dataSetWithStatuses = await _dataSetsClient.FileUploadStatusAsync(dataSet.Id, default);
dataSetWithStatuses.Dataset.Files
.All(f => f.Status is FileStatus.Processed or FileStatus.Failed)
.Should().BeTrue();
}
Expand Down
14 changes: 13 additions & 1 deletion IndicoV2.IntegrationTests/GraphQLRequest/GraphQLRequestTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using FluentAssertions;
using IndicoV2.DataSets.Models;
using IndicoV2.IntegrationTests.Utils;
using NUnit.Framework;
using Unity;
Expand Down Expand Up @@ -35,7 +36,18 @@ query ListDatasets($limit: Int){
dynamic variables = new { limit = 1 };
var request = _indicoClient.GraphQLRequest();
var result = await request.Call(query, operationName, variables);
result.Should().NotBeNull();
foreach (var datasetJson in result.GetValue("datasetsPage").GetValue("datasets"))
{
var dataset = new DataSetFull()
{
Id = datasetJson.GetValue("id"),
Name = datasetJson.GetValue("name"),
RowCount = datasetJson.GetValue("rowCount")
};
dataset.Id.Should().BeGreaterOrEqualTo(0);
dataset.Name.Should().NotBeNullOrEmpty();
dataset.RowCount.Should().BeGreaterThan(0);
}
}
}
}
7 changes: 3 additions & 4 deletions IndicoV2.IntegrationTests/Models/ModelClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public async Task GetGroup_ShouldReturnModelGroup()
}


[TestCase("Invoice Date: 2012-01-02")]
[TestCase("Invoice Date: 2012-02-03 Invoice Number: 123Test")]
[TestCase("AT&T")]
[TestCase("AT&T Xfinity T-Mobile")]
public async Task Predict_ShouldReturnPrediction(params string[] data)
{
// Arrange
Expand All @@ -75,12 +75,11 @@ public async Task Predict_ShouldReturnPrediction(params string[] data)

// Assert
predictionResults.Count.Should().Be(data.Length);

var firstPrediction = predictionResults.First().First();
firstPrediction.Label.Should().NotBeNullOrEmpty();
firstPrediction.Text.Should().NotBeNullOrEmpty();

firstPrediction.Start.Should().BeGreaterThan(0);
firstPrediction.Start.Should().BeGreaterOrEqualTo(0);
firstPrediction.End.Should().BeGreaterThan(0);

firstPrediction.Confidence.Should().NotBeEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task SnapReportAsync_ShouldGenerateReport()
[Test]
public async Task ChangeReportAsync_ShouldGenerateReport()
{
var jobId = (await _userReportingClient.CreateChangelogReportAsync(null, null, null, default))
var jobId = (await _userReportingClient.CreateChangelogReportAsync(DateTime.Now, DateTime.Today, null, default))
.UserChangelogReport.JobId;

await AssertJobGeneratesNonEmptyReport(jobId);
Expand Down
41 changes: 38 additions & 3 deletions IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ public async Task ListSubmissions_SubmissionFilterReviewInProgress_ShouldFetchSu
submissions.PageInfo.Should().NotBeNull();
submissions.Data.Should().NotBeNull();
submissions.Data.Should().HaveCount(0);

foreach (Submission submission in submissions.Data)
{
submission.Id.Should().BeGreaterThan(0);
submission.ReviewInProgress.Should().NotBeTrue();
}
}


Expand All @@ -242,12 +248,41 @@ public async Task ListSubmissions_SubmissionFilterCreatedAt_ShouldFetchSubmissio
submissions.Should().NotBeNull();
submissions.PageInfo.Should().NotBeNull();
submissions.Data.Should().NotBeNull();
var submission = submissions.Data.First();

// Assert
submissions.Data.Should().HaveCountGreaterThan(0);
submission.Id.Should().BeGreaterThan(0);
submission.Status.Should().BeOfType<SubmissionStatus>();
foreach (Submission submission in submissions.Data)
{
submission.Id.Should().BeGreaterThan(0);
submission.CreatedAt.Value.Should().BeLessThan(TimeSpan.FromTicks(DateTime.Now.Ticks));
}
}


[Test]
public async Task ListSubmissions_SubmissionFilterStatus_ShouldFetchSubmissions()
{
// Arrange
var listData = await _dataHelper.Submissions().ListAnyAsync(_workflowId);
var filters = new SubmissionFilter
{
Status = SubmissionStatus.PENDING_AUTO_REVIEW
};

// Act
var submissions = await _submissionsClient.ListAsync(null, new List<int> { listData.workflowId }, filters, 0, 10);

submissions.Should().NotBeNull();
submissions.PageInfo.Should().NotBeNull();
submissions.Data.Should().NotBeNull();
// Assert
submissions.Data.Should().HaveCountGreaterThan(0);
foreach (Submission submission in submissions.Data)
{
submission.Id.Should().BeGreaterThan(0);
submission.Status.Should().BeOfType<SubmissionStatus>();
submission.Status.Should().Be(SubmissionStatus.PENDING_AUTO_REVIEW);
}
}


Expand Down
2 changes: 1 addition & 1 deletion IndicoV2/Jobs/JobsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task<JobStatus> GetStatusAsync(string jobId, CancellationToken canc
public async Task<TResult> GetResultAsync<TResult>(string jobId, CancellationToken cancellationToken = default)
{
var result = await _strawberryShake.Jobs().GetResultAsync(jobId, cancellationToken);
// use json decoder to decode result into whatever tresult would be
// use json decoder to decode result into whatever TResult would be
return JsonConvert.DeserializeObject<TResult>(result.Job.Result);
}

Expand Down
Loading