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

Separate unit/integration tests #1902

Merged
merged 7 commits into from
Aug 7, 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
6 changes: 6 additions & 0 deletions SmiServices.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmiServices", "src\SmiServi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmiServices.UnitTests", "tests\SmiServices.UnitTests\SmiServices.UnitTests.csproj", "{080A433F-9AD6-40CD-BEB1-562ACB7A61EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmiServices.IntegrationTests", "tests\SmiServices.IntegrationTests\SmiServices.IntegrationTests.csproj", "{F9A6BC3B-A7D4-4FAF-B0C7-D270C545023B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,6 +46,10 @@ Global
{080A433F-9AD6-40CD-BEB1-562ACB7A61EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{080A433F-9AD6-40CD-BEB1-562ACB7A61EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{080A433F-9AD6-40CD-BEB1-562ACB7A61EA}.Release|Any CPU.Build.0 = Release|Any CPU
{F9A6BC3B-A7D4-4FAF-B0C7-D270C545023B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9A6BC3B-A7D4-4FAF-B0C7-D270C545023B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9A6BC3B-A7D4-4FAF-B0C7-D270C545023B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9A6BC3B-A7D4-4FAF-B0C7-D270C545023B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
12 changes: 10 additions & 2 deletions bin/smi/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
"--no-coverage",
action="store_true",
)
parser.add_argument(
group = parser.add_mutually_exclusive_group()
group.add_argument(
"--test",
nargs=1,
help="Run a specific test class",
)
group.add_argument(
"--unit-only",
action="store_true",
help="Run unit tests only"
)
args, _ = parser.parse_known_args(argv)

rc = downloadTessdata.main([])
Expand Down Expand Up @@ -73,14 +79,16 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
cmd = ("dotnet", "tool", "restore")
C.run(cmd)

f = ("--filter", args.test[0]) if args.test else ""
f = ("--filter", args.test[0]) if args.test else ()
unit_only = ("--filter", "FullyQualifiedName!~SmiServices.IntegrationTests") if args.unit_only else ()
cmd = (
"dotnet", "dotnet-coverage", "collect",
"--settings", "coverage.settings",
"--",
"dotnet", "test",
"--configuration", args.configuration,
"--no-build" if args.no_build else "",
*unit_only,
*f,
)
C.run(cmd)
Expand Down
1 change: 1 addition & 0 deletions news/1902-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Separate unit and integration tests into separate projects
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.MongoDB;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.UnitTests.Common;
using SmiServices.UnitTests.Microservices.DicomRelationalMapper;
using SynthEHR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.UnitTests.Common;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Rdmp.Core.ReusableLibraryCode.Checks;
using SmiServices.Applications.TriggerUpdates;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IdentifierMapper.Swappers;
using SmiServices.Microservices.UpdateValues;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Rdmp.Core.ReusableLibraryCode.Checks;
using SmiServices.Applications.TriggerUpdates;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IdentifierMapper.Swappers;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MongoDB.Driver;
using RabbitMQ.Client;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using System.Data.Common;

namespace SmiServices.UnitTests.Common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.Messaging;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using System;

namespace SmiServices.UnitTests.Common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.Messaging;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using SmiServices.Common.MongoDB;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using System.Threading.Tasks;

namespace SmiServices.UnitTests.Common.MongoDB
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FAnsi;
using NUnit.Framework;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortExtractor.RequestFulfillers;
using SmiServices.UnitTests.Common;
using System.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using NUnit.Framework;
using Rdmp.Core.Curation;
using Rdmp.Core.Curation.Data;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortExtractor.RequestFulfillers;
using SmiServices.UnitTests.Common;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Rdmp.Core.DataLoad.Triggers;
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortExtractor;
using SmiServices.Microservices.CohortExtractor.Audit;
using SmiServices.Microservices.CohortExtractor.RequestFulfillers;
Expand Down Expand Up @@ -262,21 +263,4 @@ private string GetUpdateTopXSql(DiscoveredTable tbl, int topXRows, string setSql

}
}

internal class TestRejector : IRejector
{
public bool Reject(IDataRecord row, [NotNullWhen(true)] out string? reason)
{
//if the image is not extractable
if (!Convert.ToBoolean(row["IsExtractableToDisk"]))
{
//tell them why and reject it
reason = (row["IsExtractableToDisk_Reason"] as string)!;
return true;
}

reason = null;
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using Rdmp.Core.Curation.Data;
using SmiServices.Common.Messages.Extraction;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortExtractor;
using SmiServices.Microservices.CohortExtractor.Audit;
using SmiServices.Microservices.CohortExtractor.RequestFulfillers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using SmiServices.Common.MessageSerialization;
using SmiServices.Common.MongoDB;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortPackager;
using SmiServices.Microservices.CohortPackager.ExtractJobStorage;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.MessageSerialization;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortPackager;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomAnonymiser;
using SmiServices.Microservices.DicomAnonymiser.Anonymisers;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Rdmp.Dicom.PipelineComponents.DicomSources.Worklists;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomRelationalMapper;
using SmiServices.Microservices.DicomRelationalMapper.Namers;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FAnsi;
using NUnit.Framework;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.DataLoad;
using Rdmp.Core.MapsDirectlyToDatabaseTable;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomRelationalMapper;
using SmiServices.Microservices.DicomRelationalMapper.Namers;
using SmiServices.UnitTests.Common;
Expand Down Expand Up @@ -66,26 +66,4 @@ public void TestCreatingNamer_CorrectType(DatabaseType dbType, string typeName,
}
}
}

public class GuidDatabaseNamerTest
{
[Test]
public void GetExampleName()
{
//t6ff062af5538473f801ced2b751c7897test_RAW
//t6ff062af5538473f801ced2b751c7897DLE_STAGING
var namer = new GuidDatabaseNamer("test", new Guid("6ff062af-5538-473f-801c-ed2b751c7897"));

var raw = namer.GetDatabaseName("test", LoadBubble.Raw);
Console.WriteLine(raw);

Assert.That(raw, Does.Contain("6ff"));

var staging = namer.GetDatabaseName("test", LoadBubble.Staging);
Console.WriteLine(staging);

Assert.That(staging, Does.Contain("6ff"));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Rdmp.Dicom.PipelineComponents.DicomSources;
using Rdmp.Dicom.TagPromotionSchema;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomRelationalMapper;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Messaging;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.CohortExtractor;
using SmiServices.Microservices.CohortExtractor.RequestFulfillers;
using SmiServices.Microservices.DicomRelationalMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using SmiServices.Common.Messaging;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.UnitTests.Common;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FAnsi;
using NUnit.Framework;
using Rdmp.Core.MapsDirectlyToDatabaseTable;
using SmiServices.IntegrationTests;
using SmiServices.UnitTests.Common;
using System.IO;
using Tests.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BadMedicine.Dicom;
using NUnit.Framework;
using SmiServices.Common.Messages;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomTagReader.Execution;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using RabbitMQ.Client;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomTagReader.Execution;
using SmiServices.Microservices.DicomTagReader.Messaging;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Moq;
using NUnit.Framework;
using SmiServices.Common.Messages;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.DicomTagReader.Execution;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using RabbitMQ.Client.Events;
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.FileCopier;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using SmiServices.Common.Messages;
using SmiServices.Common.Messaging;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IdentifierMapper;
using SmiServices.Microservices.IdentifierMapper.Swappers;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FAnsi.Discovery;
using NUnit.Framework;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IdentifierMapper.Swappers;
using SmiServices.UnitTests.Common;
using StackExchange.Redis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FAnsi.Discovery;
using NUnit.Framework;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IdentifierMapper.Swappers;
using SmiServices.UnitTests.Common;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using SmiServices.Common.Messages.Extraction;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.IsIdentifiable;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using SmiServices.Common.Messages;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.UnitTests.Common;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MongoDB.Bson;
using MongoDB.Driver;
using NUnit.Framework;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.UnitTests.Common;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using RabbitMQ.Client;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.Microservices.MongoDBPopulator.Processing;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.Microservices.MongoDBPopulator.Processing;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using RabbitMQ.Client;
using SmiServices.Common.Messages;
using SmiServices.Common.Options;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.MongoDBPopulator;
using SmiServices.Microservices.MongoDBPopulator.Processing;
using SmiServices.UnitTests.Common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FAnsi.Discovery;
using NUnit.Framework;
using SmiServices.Common.Messages.Updating;
using SmiServices.IntegrationTests;
using SmiServices.Microservices.UpdateValues;
using SmiServices.UnitTests.Common;
using System;
Expand Down
Loading
Loading