Skip to content

Commit

Permalink
Separate test project into integration and unit test project
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Jul 24, 2024
1 parent 9fbde8f commit 5d66d70
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 31 deletions.
34 changes: 34 additions & 0 deletions src/AssemblyAI.IntegrationTests/AssemblyAI.IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="NUnit" Version="3.14.0"/>
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AssemblyAI\AssemblyAI.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="TestData\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NUnit.Framework;

namespace AssemblyAI.Test;
namespace AssemblyAI.IntegrationTests;

[TestFixture]
public class FilesClientTests
Expand Down
147 changes: 147 additions & 0 deletions src/AssemblyAI.IntegrationTests/LemurTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
namespace AssemblyAI.IntegrationTests;

[TestFixture]
public class LemurTests
{
private string ApiKey
{
get
{
var apiKey = TestContext.Parameters.Get("ASSEMBLYAI_API_KEY");
if (string.IsNullOrEmpty(apiKey))
throw new Exception("ASSEMBLYAI_API_KEY .runsettings parameter is not set.");
return apiKey;
}
}

private string[] TranscriptIds
{
get
{
var transcriptIds = TestContext.Parameters.Get("TEST_TRANSCRIPT_IDS");
if (string.IsNullOrEmpty(transcriptIds))
throw new Exception("TEST_TRANSCRIPT_IDS .runsettings parameter is not set.");
return transcriptIds.Split(',');
}
}

// TODO: uncomment when Fern fixes params generation
/*[Test]
public async Task Should_Generate_Summary()
{
var client = new AssemblyAIClient(ApiKey);
var response = await client.Lemur.SummaryAsync(new LemurSummaryParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds,
AnswerFormat = "one sentence"
}).ConfigureAwait(false);
Assert.That(response, Is.Not.Null);
Assert.That(response.RequestId, Is.Not.Empty);
Assert.That(response.Response, Is.Not.Empty);
}
[Test]
public async Task Should_Generate_Answer()
{
var client = new AssemblyAIClient(ApiKey);
var response = await client.Lemur.QuestionAnswerAsync(new LemurQuestionAnswerParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds,
Questions = new[]
{
new LemurQuestion
{
Question = "What are they discussing?",
AnswerFormat = "text"
}
}
}).ConfigureAwait(false);
Assert.That(response, Is.Not.Null);
Assert.That(response.RequestId, Is.Not.Empty);
Assert.That(response.Response, Is.Not.Empty);
Assert.That(response.Response.First().Question, Is.Not.Empty);
Assert.That(response.Response.First().Answer, Is.Not.Empty);
}
[Test]
public async Task Should_Generate_Action_Items()
{
var client = new AssemblyAIClient(ApiKey);
var response = await client.Lemur.ActionItemsAsync(new LemurActionItemsParams()
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds
}).ConfigureAwait(false);
Assert.That(response, Is.Not.Null);
Assert.That(response.RequestId, Is.Not.Empty);
Assert.That(response.Response, Is.Not.Empty);
}
[Test]
public async Task Should_Generate_Task()
{
var client = new AssemblyAIClient(ApiKey);
var response = await client.Lemur.TaskAsync(new LemurTaskParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds,
Prompt = "Write a haiku about this conversation."
}).ConfigureAwait(false);
Assert.That(response, Is.Not.Null);
Assert.That(response.RequestId, Is.Not.Empty);
Assert.That(response.Response, Is.Not.Empty);
}
[Test]
public void Should_Fail_To_Generate_Summary()
{
var client = new AssemblyAIClient(ApiKey);
var ex = Assert.ThrowsAsync<Exception>(async () => await client.Lemur.SummaryAsync(new LemurSummaryParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = ["bad-id"],
AnswerFormat = "one sentence"
}).ConfigureAwait(false));
Assert.That(ex.Message, Is.EqualTo("each transcript source id must be valid"));
}
[Test]
public async Task Should_Return_Response()
{
var client = new AssemblyAIClient(ApiKey);
var taskResponse = await client.Lemur.TaskAsync(new LemurTaskParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds,
Prompt = "Write a haiku about this conversation."
}).ConfigureAwait(false);
var taskResponse2OneOf = await client.Lemur.GetResponseAsync(taskResponse.RequestId).ConfigureAwait(false);
var taskResponse2 = (LemurStringResponse) taskResponse2OneOf.Value;
Assert.That(taskResponse2.RequestId, Is.EqualTo(taskResponse.RequestId));
Assert.That(taskResponse2.Response, Is.EqualTo(taskResponse.Response));
}
[Test]
public async Task Should_Purge_Request_Data()
{
var client = new AssemblyAIClient(ApiKey);
var summaryResponse = await client.Lemur.SummaryAsync(new LemurSummaryParams
{
FinalModel = LemurModel.Basic,
TranscriptIds = TranscriptIds,
AnswerFormat = "one sentence"
}).ConfigureAwait(false);
var deletionRequest = await client.Lemur.PurgeRequestDataAsync(summaryResponse.RequestId).ConfigureAwait(false);
Assert.That(deletionRequest.Deleted, Is.True);
Assert.That(summaryResponse.RequestId, Is.EqualTo(deletionRequest.RequestIdToPurge));
}*/
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NUnit.Framework;

namespace AssemblyAI.Test;
namespace AssemblyAI.IntegrationTests;

[TestFixture]
public class TranscriptsClientTests
Expand Down Expand Up @@ -30,18 +28,6 @@ private string TranscriptId
}
}


private string[] TranscriptIds
{
get
{
var transcriptIds = TestContext.Parameters.Get("TEST_TRANSCRIPT_IDS");
if (string.IsNullOrEmpty(transcriptIds))
throw new Exception("TEST_TRANSCRIPT_IDS .runsettings parameter is not set.");
return transcriptIds.Split(',').ToArray();
}
}

[Test]
public async Task Should_Submit_Using_Uri()
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,4 @@
<ProjectReference Include="..\AssemblyAI\AssemblyAI.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="TestData\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Text.Json;
using AssemblyAI.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NUnit.Framework;

namespace AssemblyAI.Test;
namespace AssemblyAI.UnitTest;

[TestFixture]
public class DependencyInjectionClientOptionsTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using NUnit.Framework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NUnit.Framework;

namespace AssemblyAI.Test;
namespace AssemblyAI.UnitTest;

[TestFixture]
public class DiClientTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NUnit.Framework;

namespace AssemblyAI.Test;
namespace AssemblyAI.UnitTest;

[TestFixture]
public class UserAgentTests
Expand Down
8 changes: 7 additions & 1 deletion src/AssemblyAI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyAI", "AssemblyAI\AssemblyAI.csproj", "{6908A082-04F2-4B91-92F1-671DEA06C378}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyAI.Test", "AssemblyAI.Test\AssemblyAI.Test.csproj", "{4C5A0575-B891-42AA-8F7A-92424E2E27C0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyAI.UnitTest", "AssemblyAI.UnitTest\AssemblyAI.UnitTest.csproj", "{4C5A0575-B891-42AA-8F7A-92424E2E27C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyAI.IntegrationTests", "AssemblyAI.IntegrationTests\AssemblyAI.IntegrationTests.csproj", "{F68D755B-BF68-496C-860B-1F7CB8F579D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -24,5 +26,9 @@ Global
{4C5A0575-B891-42AA-8F7A-92424E2E27C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C5A0575-B891-42AA-8F7A-92424E2E27C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C5A0575-B891-42AA-8F7A-92424E2E27C0}.Release|Any CPU.Build.0 = Release|Any CPU
{F68D755B-BF68-496C-860B-1F7CB8F579D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F68D755B-BF68-496C-860B-1F7CB8F579D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F68D755B-BF68-496C-860B-1F7CB8F579D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F68D755B-BF68-496C-860B-1F7CB8F579D3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 5d66d70

Please sign in to comment.