Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / CI policy (pull_request) Failing after 2s
Heimdall Gitea / Build and tests (pull_request) Failing after 15m37s
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System.Text.Json;
|
|
using Heimdall.Agent.Services;
|
|
using Heimdall.Domain.Enums;
|
|
|
|
namespace Heimdall.Agent.Tests;
|
|
|
|
public sealed class AnalysisJobPollingServiceTests
|
|
{
|
|
private static readonly DetectionResult[] CocoDetections =
|
|
[
|
|
new("person", 0.91f, 0.1f, 0.2f, 0.2f, 0.5f, 0),
|
|
new("bicycle", 0.82f, 0.2f, 0.2f, 0.3f, 0.4f, 1),
|
|
new("car", 0.88f, 0.4f, 0.3f, 0.4f, 0.3f, 2),
|
|
new("bus", 0.77f, 0.5f, 0.2f, 0.3f, 0.4f, 5),
|
|
];
|
|
|
|
[Fact]
|
|
public void SelectDetections_PersonDetection_ReturnsOnlyPersonClass()
|
|
{
|
|
var result = AnalysisJobPollingService.SelectDetections(AnalysisJobType.PersonDetection, CocoDetections);
|
|
|
|
result.Select(d => d.Label).ShouldBe(["person"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void SelectDetections_VehicleClassification_ReturnsCocoMotorVehicles()
|
|
{
|
|
var result = AnalysisJobPollingService.SelectDetections(AnalysisJobType.VehicleClassification, CocoDetections);
|
|
|
|
result.Select(d => d.Label).ShouldBe(["car", "bus"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void SelectDetections_ObjectDetection_PreservesAllModelClasses()
|
|
{
|
|
var result = AnalysisJobPollingService.SelectDetections(AnalysisJobType.ObjectDetection, CocoDetections);
|
|
|
|
result.ShouldBe(CocoDetections);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("\"PersonDetection\"", true)]
|
|
[InlineData("\"vehicLeClassification\"", true)]
|
|
[InlineData("3", true)]
|
|
[InlineData("5", true)]
|
|
[InlineData("0", false)]
|
|
[InlineData("\"FaceRecognition\"", false)]
|
|
[InlineData("\"not-a-job\"", false)]
|
|
public void SupportedJobTypes_AcceptsOnlyImplementedContracts(string json, bool expected)
|
|
{
|
|
using var document = JsonDocument.Parse(json);
|
|
var actual = AnalysisJobPollingService.TryGetSupportedJobType(document.RootElement, out _);
|
|
|
|
actual.ShouldBe(expected);
|
|
}
|
|
}
|